-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
53 lines (52 loc) · 1.29 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
import { defineConfig, loadEnv } from 'vite'
import type { ConfigEnv, UserConfig } from 'vite'
import { createVitePlugins, getRootPath, getSrcPath } from './build'
export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
const root = getRootPath()
const srcPath = getSrcPath()
const { VITE_ENABLE_ANALYZE, VITE_BUILD_COMPRESS } = loadEnv(mode, root)
const isBuild = command === 'build'
return {
resolve: {
alias: {
'~': root,
'@': srcPath,
'#': getSrcPath('types'),
},
},
server: {
host: true,
},
esbuild: {
drop: isBuild ? ['console', 'debugger'] : [],
},
build: {
target: 'es2015',
cssTarget: 'chrome80',
reportCompressedSize: false,
chunkSizeWarningLimit: 1500,
rollupOptions: {
output: {
// 入口文件名
entryFileNames: 'assets/[name].js',
manualChunks: {
vue: ['vue', 'pinia', 'vue-router'],
},
},
},
},
plugins: createVitePlugins({
isBuild,
enableAnalyze: VITE_ENABLE_ANALYZE === 'true',
compress: VITE_BUILD_COMPRESS,
}),
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
javascriptEnabled: true,
},
},
},
}
})