perf: only process images when building for production
This commit is contained in:
parent
d0b191706b
commit
3adbabc7da
1 changed files with 23 additions and 21 deletions
|
@ -51,26 +51,28 @@ module.exports = {
|
||||||
return args;
|
return args;
|
||||||
});
|
});
|
||||||
|
|
||||||
config.module
|
if (process.env.NODE_ENV === "production") {
|
||||||
.rule("images")
|
config.module
|
||||||
.test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/i)
|
.rule("images")
|
||||||
.use("image-webpack-loader")
|
.test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/i)
|
||||||
.loader("image-webpack-loader")
|
.use("image-webpack-loader")
|
||||||
.tap((options) => {
|
.loader("image-webpack-loader")
|
||||||
const newOpts = {
|
.tap((options) => {
|
||||||
mozjpeg: {
|
const newOpts = {
|
||||||
progressive: true,
|
mozjpeg: {
|
||||||
quality: 75,
|
progressive: true,
|
||||||
},
|
quality: 75,
|
||||||
pngquant: {
|
},
|
||||||
quality: [0.65, 0.9],
|
pngquant: {
|
||||||
speed: 4,
|
quality: [0.65, 0.9],
|
||||||
},
|
speed: 4,
|
||||||
gifsicle: {
|
},
|
||||||
interlaced: false,
|
gifsicle: {
|
||||||
},
|
interlaced: false,
|
||||||
};
|
},
|
||||||
return { ...options, ...newOpts };
|
};
|
||||||
});
|
return { ...options, ...newOpts };
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue