慕粉4187235
2017-04-01 01:30
ERROR in ./src/assets/1.jpg
Module build failed: TypeError: Cannot read property 'bypassOnDebug' of null
at Object.module.exports (F:\webpack\webpack-demo1\node_modules\image-webpack-loader\index.js:30:26)
The LoaderOptionsPlugin is to make the transition from webpack 1 easier. In webpack 2 you should define the options directly on the loader.
Your rule would look like this (using the webpack 2 rule from the README with your options):
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
quality: 65,
},
pngquant: {
quality: '65-90',
speed: 4,
},
svgo: {
plugins: [
{
removeViewBox: false,
},
{
removeEmptyAttrs: false,
},
],
}
}
}
]}
一运行也是爆这个错
如果写成这样image-webpack-loader?bypassOnDebug,他直接notfounderror了
'image-webpack-loader?bypassOnDebug' 建议看一下npm上的描述。https://www.npmjs.com/package/image-webpack-loader
同问这个问题,尝试过使用img-loader可以正常编译,是可以压缩图片的
同问这个问题,尝试过使用img-loader可以正常编译,但是没有压缩图片。
webpack深入与实战
86561 学习 · 721 问题
相似问题