【发布时间】:2017-04-21 14:33:28
【问题描述】:
我正在尝试将 webpack2 与 express 一起使用,但我似乎无法提供我的字体,js 文件工作正常,请帮助 这是我的 webpack.config
const devConfig = {
devtool: '#source-map',
entry: [
'./public/js/entry.js',
'webpack/hot/dev-server',
'webpack-hot-middleware/client'
]
,
output: {
filename: './js/main.js',
path: '/',
publicPath: publicPath
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
],
module: {
rules: [
{
test: /\.s(a|c)ss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
{
test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?'
}
]
}
};
在我的 scss 文件中,我有这个
src: url('../font-files/firasans-extralightitalic-webfont.woff2') format('woff2'), url('../font-files/firasans-extralightitalic-webfont.woff') format('woff');
虽然我不断收到此错误
找不到模块:错误:无法解析 '../font-files/firasans-extralightitalic-webfont.woff2'
谁能告诉我怎么了...我看到其他人在 js 文件中添加了字体,但我真的不喜欢那样做
【问题讨论】:
标签: javascript express webpack