-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathvite.config.ts
45 lines (43 loc) · 1.08 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
import { defineConfig, loadEnv, Plugin } from 'vite';
import vue from '@vitejs/plugin-vue';
import legacy from '@vitejs/plugin-legacy';
import windi from 'vite-plugin-windicss';
import compression from 'vite-plugin-compression';
import visualizer from 'rollup-plugin-visualizer';
export default defineConfig(({ mode }) => {
const env = (loadEnv(mode, __dirname) as unknown) as CustomEnvVariables;
return {
base: env.VITE_BASE_URL,
plugins: [
vue(),
windi(),
mode === 'report' &&
visualizer({
filename: './dist/_report.html',
open: mode === 'report',
}),
legacy(),
env.VITE_GZIP === 'on' &&
compression({
algorithm: 'gzip',
ext: '.gz',
}),
env.VITE_BROTLI === 'on' &&
compression({
algorithm: 'brotliCompress',
ext: '.br',
}),
].filter(Boolean) as Plugin[],
resolve: {
alias: {
'@': '/src',
},
},
server: {
open: true,
},
build: {
sourcemap: env.VITE_SOURCE_MAP === 'on',
},
};
});