简体   繁体   English

webpack bootstrap sass字体url

[英]webpack bootstrap sass fonts url

I've configured my fonts to be put in a /fonts folder 我已经将字体配置为放在/ fonts文件夹中

{test: /\\.(eot|svg|ttf)$/, loader: "file?name=fonts/[name].[ext]?[hash]"}

and my sass is being converted to css and extracted to the /css folder as per below 和我的SASS被转换为CSS并提取到/ css文件夹,如下所示

{test: /\.scss/, loader: ExtractTextPlugin.extract("style", "css!sass")}

and

new ExtractTextPlugin("css/styles.css", {
    allChunks: true
})

The issue is that when I view via web browser by using browser sync and serving from my /dist folder which has those 2 folders mentioned above inside, the css tries to load fonts by going to /css/fonts. 问题是,当我通过浏览器同步通过Web浏览器查看并从我的/ dist文件夹(其中包含上述2个文件夹)提供服务时,css尝试通过转到/ css / fonts来加载字体。 Can anyone help? 有人可以帮忙吗?

In the end I just had to update my loaders to have a / at the front of my file param eg 最后,我只需要更新装入程序,使其在文件参数的前面有一个/,例如

{test: /\\.(eot|svg|ttf)$/, loader: "file?name=/fonts/[name].[ext]?[hash]"}

instead of 代替

{test: /\\.(eot|svg|ttf)$/, loader: "file?name=fonts/[name].[ext]?[hash]"}

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

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