繁体   English   中英

更改Webpack混合Laravel中的字体编译路径

[英]change font compile path in webpack mix laravel

我正在使用laravel mix,我想编译我的字体。 我的字体已编译,但其名称是从根读取的。 请参阅底部的代码。

@font-face {
  font-family: 'icomoon';
  src:  url('../fonts/product-fonts/icomoon.eot');
  src:  url('../fonts/product-fonts/icomoon.eot') format('embedded-opentype'),
        url('../fonts/product-fonts/icomoon.ttf') format('truetype'),
        url('../fonts/product-fonts/icomoon.woff') format('woff'),
        url('../fonts/product-fonts/icomoon.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

这是我的sass代码,最终编译如下:

@font-face {
  font-family: 'icomoon';
  src: url(/fonts/icomoon.eot?c2f80bad46e9a20b6278361015fef1cd);
  src: url(/fonts/icomoon.eot?c2f80bad46e9a20b6278361015fef1cd) format("embedded-opentype"), url(/fonts/icomoon.ttf?5fa3cdef859a193e0f02c75fbd91d73a) format("truetype"), url(/fonts/icomoon.woff?96c27a3f7e16f9927cc8a0d2818c4e8e) format("woff"), url(/fonts/icomoon.svg?6e4d8f919ddb5d210c8807eb99149359) format("svg");
  font-weight: normal;
  font-style: normal;
}

但我要编译以下内容:

@font-face {
  font-family: 'icomoon';
  src: url(../fonts/icomoon.eot?c2f80bad46e9a20b6278361015fef1cd);
  src: url(../fonts/icomoon.eot?c2f80bad46e9a20b6278361015fef1cd) format("embedded-opentype"), url(../fonts/icomoon.ttf?5fa3cdef859a193e0f02c75fbd91d73a) format("truetype"), url(../fonts/icomoon.woff?96c27a3f7e16f9927cc8a0d2818c4e8e) format("woff"), url(../fonts/icomoon.svg?6e4d8f919ddb5d210c8807eb99149359) format("svg");
  font-weight: normal;
  font-style: normal;
}

因为我的css文件在另一个文件夹中

尝试设置资源根

mix.setResourceRoot( '../');

这对我来说很好:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM