我正在从 gulp 过渡到 webpack,我在一个static/img
文件夹中有图像,我想处理这些图像image-webpack-loader
,然后复制到一个build/public/img
文件夹中。file-loader
我想用这个吗?问题是图像没有被复制。事实上,这个加载器似乎在构建过程中被忽略了。
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
module.exports = {
context: path.resolve(__dirname, 'static'),
entry: ['./js/frontend.js','./sass/app.scss'],
output: {
path: path.join(__dirname, 'build/public'),
filename: 'js/frontend.js'
},
module: {
rules: [
{
test: /\.(jpe?g|png|gif|svg)$/,
loader: [
'file-loader?name=img/[name].[ext]',
'image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /\.(sass|scss)$/,
loader: ExtractTextPlugin.extract({
use: [{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}]
})
}
]
},
plugins: [
new ExtractTextPlugin({
filename: 'css/styles.css',
allChunks: true
})
],
devtool: 'source-map'
};