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