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;
|
||||
});
|
||||
|
||||
config.module
|
||||
.rule("images")
|
||||
.test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/i)
|
||||
.use("image-webpack-loader")
|
||||
.loader("image-webpack-loader")
|
||||
.tap((options) => {
|
||||
const newOpts = {
|
||||
mozjpeg: {
|
||||
progressive: true,
|
||||
quality: 75,
|
||||
},
|
||||
pngquant: {
|
||||
quality: [0.65, 0.9],
|
||||
speed: 4,
|
||||
},
|
||||
gifsicle: {
|
||||
interlaced: false,
|
||||
},
|
||||
};
|
||||
return { ...options, ...newOpts };
|
||||
});
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
config.module
|
||||
.rule("images")
|
||||
.test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/i)
|
||||
.use("image-webpack-loader")
|
||||
.loader("image-webpack-loader")
|
||||
.tap((options) => {
|
||||
const newOpts = {
|
||||
mozjpeg: {
|
||||
progressive: true,
|
||||
quality: 75,
|
||||
},
|
||||
pngquant: {
|
||||
quality: [0.65, 0.9],
|
||||
speed: 4,
|
||||
},
|
||||
gifsicle: {
|
||||
interlaced: false,
|
||||
},
|
||||
};
|
||||
return { ...options, ...newOpts };
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue