Skip to content

Commit 0f068df

Browse files
committed
fix bugbot (webpack): register ImageMinimizerPlugin in optimization.minimizer
Move image minimization out of the plugins array so it runs in webpack’s optimization pipeline. Keeps SVGO config wired as svgoconfig for imagemin-svgo.
1 parent 559d8e5 commit 0f068df

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

‎config/plugins.js‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const path = require('path')
2-
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin')
3-
const svgoconfig = require('./svgo.config')
42
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
53
const { WebpackManifestPlugin } = require('webpack-manifest-plugin')
64
const ESLintPlugin = require('eslint-webpack-plugin')
@@ -63,21 +61,6 @@ module.exports = {
6361
]
6462

6563
if (mode === 'production') {
66-
plugins.push(
67-
new ImageMinimizerPlugin({
68-
minimizer: {
69-
implementation: ImageMinimizerPlugin.imageminMinify,
70-
options: {
71-
plugins: [
72-
['gifsicle', { interlaced: true }],
73-
['jpegtran', { progressive: true }],
74-
['optipng', { optimizationLevel: 5 }],
75-
['svgo', svgoconfig],
76-
],
77-
},
78-
},
79-
})
80-
)
8164
plugins.push(
8265
new BundleAnalyzerPlugin({
8366
analyzerMode: 'json',

‎config/webpack.common.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const path = require('path')
22
const entries = require('./entries')
3+
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin')
34
const TerserPlugin = require('terser-webpack-plugin')
5+
const svgoconfig = require('./svgo.config')
46

57
module.exports = {
68
entry: entries,
@@ -12,6 +14,19 @@ module.exports = {
1214
},
1315
optimization: {
1416
minimizer: [
17+
new ImageMinimizerPlugin({
18+
minimizer: {
19+
implementation: ImageMinimizerPlugin.imageminMinify,
20+
options: {
21+
plugins: [
22+
['gifsicle', { interlaced: true }],
23+
['jpegtran', { progressive: true }],
24+
['optipng', { optimizationLevel: 5 }],
25+
['svgo', svgoconfig],
26+
],
27+
},
28+
},
29+
}),
1530
new TerserPlugin({
1631
parallel: true,
1732
terserOptions: {

0 commit comments

Comments
 (0)