我正在尝试通过webpack文件加载器输出所有图像文件,但是webpack无法识别PNG扩展名的图像。然而,在JPG文件上配置正常工作。
我的webpack配置如下:
我的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]'
}]
}
};