perf: only process images when building for production

This commit is contained in:
Sebin Nyshkim 2022-01-11 21:56:42 +01:00
parent d0b191706b
commit 3adbabc7da

View file

@ -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 };
});
}
},
};