Skip to content

Commit 8651e7f

Browse files
committed
feat (images): image-webpack-loader => image-minimizer-webpack-plugin
1 parent 365fbf0 commit 8651e7f

File tree

4 files changed

+235
-2306
lines changed

4 files changed

+235
-2306
lines changed

config/loaders.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,6 @@ module.exports = {
2121
type: 'asset/resource',
2222
exclude: /icons/,
2323
include: srcPath + '/img',
24-
use: [
25-
{
26-
loader: 'image-webpack-loader',
27-
options: {
28-
mozjpeg: {
29-
progressive: true,
30-
quality: 65,
31-
},
32-
pngquant: {
33-
quality: [0.65, 0.9],
34-
speed: 4,
35-
},
36-
gifsicle: {
37-
interlaced: false,
38-
},
39-
webp: {
40-
quality: 75,
41-
},
42-
},
43-
},
44-
],
4524
},
4625
/* JSLoader */ {
4726
test: /\.js$/i,

config/webpack.common.js

Lines changed: 18 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,22 @@ module.exports = {
1214
},
1315
optimization: {
1416
minimizer: [
17+
new ImageMinimizerPlugin({
18+
minimizer: {
19+
implementation: ImageMinimizerPlugin.imageminMinify,
20+
options: {
21+
// Lossless optimization with custom option
22+
// Feel free to experiment with options for better result for you
23+
plugins: [
24+
['gifsicle', { interlaced: true }],
25+
['jpegtran', { progressive: true }],
26+
['optipng', { optimizationLevel: 5 }],
27+
// Svgo configuration here https://github.com/svg/svgo#configuratio
28+
['svgo', { svgoconfig }],
29+
],
30+
},
31+
},
32+
}),
1533
new TerserPlugin({
1634
parallel: true,
1735
terserOptions: {

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"dependencies": {
1717
"lazysizes": "^5.3.2",
1818
"oneloop.js": "^5.0.0",
19-
"sharp": "^0.32.0",
2019
"what-input": "^5.2.10"
2120
},
2221
"devDependencies": {
@@ -35,7 +34,7 @@
3534
"eslint-config-prettier": "^8.5.0",
3635
"eslint-plugin-prettier": "^4.2.1",
3736
"eslint-webpack-plugin": "^3.2.0",
38-
"image-webpack-loader": "^7.0.1",
37+
"image-minimizer-webpack-plugin": "^3.8.2",
3938
"js-yaml": "^4.1.0",
4039
"json2csv": "^5.0.6",
4140
"mini-css-extract-plugin": "^1.5.0",
@@ -51,12 +50,14 @@
5150
"prettier": "^2.2.1",
5251
"sass": "^1.52.3",
5352
"sass-loader": "^11.0.1",
53+
"sharp": "^0.32.1",
5454
"style-loader": "^2.0.0",
5555
"stylelint": "^14.13.0",
5656
"stylelint-config-recess-order": "^3.0.0",
5757
"stylelint-scss": "^4.3.0",
5858
"stylelint-webpack-plugin": "^3.3.0",
5959
"svg-sprite-loader": "^6.0.10",
60+
"svgo": "^3.0.2",
6061
"svgo-loader": "^3.0.0",
6162
"terser-webpack-plugin": "^5.3.6",
6263
"webpack": "^5.35.0",

0 commit comments

Comments
 (0)