-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
82 lines (80 loc) · 1.78 KB
/
vite.config.ts
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
75
76
77
78
79
80
81
82
import path from 'node:path';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer';
import { createHtmlPlugin } from 'vite-plugin-html';
import viteImagemin from 'vite-plugin-imagemin';
import svgr from 'vite-plugin-svgr';
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
esbuild: {
legalComments: 'eof',
},
build: {
manifest: true,
sourcemap: true,
},
css: {
devSourcemap: true,
postcss: './.postcssrc.json',
},
plugins: [
react(),
svgr({
svgrOptions: {
dimensions: false,
},
}),
createHtmlPlugin({
minify: true,
inject: {
data: {
googleSiteVerificationToken: env.GOOGLE_SITE_VERIFICATION_TOKEN,
},
},
}),
viteImagemin({
disable: command !== 'build',
optipng: {
optimizationLevel: 5,
},
mozjpeg: {
quality: 75,
},
svgo: {
plugins: [
{
name: 'removeViewBox',
active: false,
},
{
name: 'removeDimensions',
active: true,
},
],
},
}),
...(env.VITE_STATS
? [
visualizer({
filename: 'build-stats.html',
gzipSize: true,
open: true,
template: 'treemap',
}),
]
: []),
],
resolve: {
alias: {
'@': path.resolve('./src'),
},
},
server: {
host: '0.0.0.0',
...(env.PORT && { port: Number(env.PORT) }),
strictPort: true,
},
};
});