-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
42 lines (41 loc) · 913 Bytes
/
vite.config.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
import imagemin from 'imagemin'
import imageminWebp from 'imagemin-webp'
import path from 'path'
import { defineConfig } from 'vite'
import glob from 'fast-glob'
import { fileURLToPath } from 'url'
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
export default defineConfig({
plugins: [
ViteImageOptimizer({
png: {
quality: 70,
},
jpeg: {
quality: 70,
},
jpg: {
quality: 70,
},
}),
{
...imagemin(['./src/img/**/*.{jpg,png,jpeg}'], {
destination: './src/img/webp/',
plugins: [
imageminWebp({ quality: 70 })
]
}),
apply: 'serve',
}
],
build: {
rollupOptions: {
input: Object.fromEntries(
glob.sync(['./*.html', './pages/**/*.html']).map(file => [
path.relative(__dirname, file.slice(0, file.length - path.extname(file).length)),
fileURLToPath(new URL(file, import.meta.url))
])
)
},
},
})