-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.js
63 lines (61 loc) · 1.31 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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';
// you can use our path for your project
const rootPath = '/'
// example: const rootPath = '/my-path/'
export default defineConfig({
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: ['legacy-js-api'],
}
}
},
plugins: [
ViteImageOptimizer({
svg: {
plugins: [
'removeDoctype',
'removeXMLProcInst',
'minifyStyles',
'sortAttrs',
'sortDefsChildren',
],
},
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))
])
)
},
},
base: `${rootPath}`,
})