嘿伙计们(使用webpack 2.1.0-beta.22)所以我在webpack.base.js
中有以下配置:
entry: {
client: "./client/index.js"
},
output: {
path: _.outputPath,
filename: '[name].js',
publicPath: '/themes/default/dist/'
},
module: {
loaders: [
{
test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
loader: 'file',
query: {
name: 'media/[name].[hash:8].[ext]'
}
}
]
}
这是我的webpack.dev.js
:
const cssImagePath = path.resolve('../..');`
base.module.loaders.push(
{
test: /\.(s?)css$/,
loaders: [
'style-loader',
`css-loader?sourceMap&root=${cssImagePath}`,
'sass-loader?outputStyle=expanded&sourceMap&sourceMapContents'
]
}
)
现在我在scss
文件中添加了这一行:background-image: url('/themes/default/client/images/snow-flake.png');
如果我运行webpack并使用检查器,则路径将被替换为:url(/themes/default/dist/media/snow-flake.0af467e3.png)
哪个看起来很完美的问题是file-loader
没有创建/复制到该目录,因此themes/default/dist/media
不存在?
有人遇到过这个吗?