-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagemin.js
74 lines (67 loc) · 1.61 KB
/
imagemin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'use strict'
const imagemin = require('imagemin')
const mozjpeg = require('imagemin-mozjpeg')
const jpegtran = require('imagemin-jpegtran')
const optipng = require('imagemin-optipng')
const advpng = require('imagemin-advpng')
const pngquant = require('imagemin-pngquant')
const svgo = require('imagemin-svgo')
const webp = require('imagemin-webp')
// Same config as in ./webpack/image-webpack-loader.js
imagemin(
['./src/assets/*.{jpg,png,svg}'],
'output/imagemin-image-webpack-loader-config',
{
plugins: [
mozjpeg({
progressive: true,
quality: 65,
}),
pngquant({
quality: [0.65, 0.9],
speed: 4,
}),
svgo({
removeViewBox: false,
}),
],
}
)
// https://github.com/tomchentw/imagemin-lint-staged/blob/master/lib/index.js
imagemin(
['./src/assets/*.{jpg,png,svg}'],
'output/imagemin-lint-staged-config',
{
plugins: [
jpegtran({
progressive: true,
}),
optipng({
optimizationLevel: 5,
}),
svgo({
removeViewBox: false,
}),
],
}
)
/*
Some basic values from https://web.dev/ + advgpng from https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/automating-image-optimization/#closing-recommendations
*/
imagemin(['./src/assets/*.{jpg,png,svg}'], 'output/imagemin-webdev', {
plugins: [
mozjpeg({
quality: 50,
}),
pngquant({
quality: [0.49, 0.5],
}),
advpng(),
svgo({
removeViewBox: false,
}),
],
})
imagemin(['./src/assets/*.{jpg,png}'], 'output/imagemin-webp', {
use: [webp({ quality: 50 })],
})