首先贴报错:
webpack配置如下:
module.exports = {
entry: {
app: './src/index.js',
search: './src/search.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[chunkhash:8].js'
},
mode:'development',
module: {
rules: [
{
test: /.(woff|woff2|eot|ttf|otf)$/,
use: 'file-loader',
options: {
name: '[name][hash:8].[ext]'
}
}
]
}
}
这里面我配置了字体(或者图片)的hash配置:
options: { name: '[name][hash:8].[ext]'}
报错是说options没有提供一个loader去配置name,大致的意思。
解决方案:
{
test: /.(woff|woff2|eot|ttf|otf)$/,
// use: 'file-loader',
// options: {
// name: 'img/[name][hash:8].[ext]'
// }
use: [
{
loader: 'file-loader',
query: {
name: '[name].[hash:8].[ext]'
}
}
]
}