Skip to content

Commit 69e57c4

Browse files
committed
Remove imagemin and binary plugins (gifsicle, jpegtran, optipng). Use ImageMinimizerPlugin sharpMinify and svgoMinify, add svgo as a direct devDependency, and align svgo.config with SVGO v4.
1 parent 39220fd commit 69e57c4

4 files changed

Lines changed: 434 additions & 2867 deletions

File tree

‎config/svgo.config.js‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ module.exports = {
22
plugins: [
33
{
44
name: 'preset-default',
5-
params: {
6-
overrides: {
7-
// Disable a plugin included by default that you don't want (false)
8-
removeViewBox: false,
9-
},
10-
},
5+
},
6+
{
7+
name: 'removeViewBox',
8+
active: false,
119
},
1210
// Plugins that are not in the "preset-default" and that you want to activate
1311
'removeTitle',

‎config/webpack.common.js‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,37 @@ module.exports = {
1515
optimization: {
1616
minimizer: [
1717
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-
],
18+
minimizer: [
19+
{
20+
implementation: ImageMinimizerPlugin.sharpMinify,
21+
filter: (source, sourcePath) => !/\.svg$/i.test(sourcePath),
22+
options: {
23+
encodeOptions: {
24+
jpeg: {
25+
quality: 100,
26+
progressive: true,
27+
},
28+
jpg: {
29+
quality: 100,
30+
progressive: true,
31+
},
32+
png: {
33+
compressionLevel: 9,
34+
},
35+
gif: {},
36+
},
37+
},
2738
},
28-
},
39+
{
40+
implementation: ImageMinimizerPlugin.svgoMinify,
41+
options: {
42+
encodeOptions: {
43+
multipass: true,
44+
...svgoconfig,
45+
},
46+
},
47+
},
48+
],
2949
}),
3050
new TerserPlugin({
3151
parallel: true,

0 commit comments

Comments
 (0)