我正在尝试通过 webpack 文件加载器输出所有图像文件,但是 webpack 忽略了带有 PNG 扩展名的图像。配置适用于 JPG 文件。
我的 webpack 配置:
const path = require('path');
const PATHS = {
src: path.join(__dirname, 'src'),
img: path.join(__dirname, 'src/img'),
styles: path.join(__dirname, 'src/styles'),
build: path.join(__dirname, 'build')
}
module.exports = {
context: PATHS.src,
entry: {
script: ['./scripts/main.js', './styles/main.scss'],
index: './index.html'
},
output: {
path: PATHS.build,
filename: '[name].js'
},
module: {
loaders: [{
test: /\.scss$/,
loaders: ["style", "css", "sass"],
include: PATHS.styles
}, {
test: /\.(png|jpg)$/i,
loader: 'file?name=[path][name].[ext]',
include: PATHS.img
}, {
test: /\.(html)$/,
loader: 'file?name=[path][name].[ext]'
}]
}
};