forked from csx-bill/quick-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
75 lines (69 loc) · 1.95 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
import type { ConfigEnv, UserConfig } from 'vite'
import { loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { wrapperEnv } from './build/utils'
// 需要安装 @typings/node 插件
import { resolve } from 'path'
/** @type {import('vite').UserConfig} */
export default ({ command, mode }: ConfigEnv): UserConfig => {
const root = process.cwd()
const isBuild = command === 'build'
const env = loadEnv(mode, root)
// this function can be converted to different typings
const viteEnv: any = wrapperEnv(env)
const { VITE_PORT, VITE_DROP_CONSOLE } = viteEnv
return {
base: './',
server: {
// 自定义本地开发服务器
proxy: {
'/api': {
target: "http://118.89.55.165",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, 'api'),
},
},
host: true,
open: true,
port: VITE_PORT
},
plugins: [
react(),
createSvgIconsPlugin({
iconDirs: [resolve(process.cwd(), 'src/assets/icons')],
symbolId: 'icon-[dir]-[name]'
}),
],
build: {
target: 'es2015',
cssTarget: 'chrome86',
minify: 'terser',
terserOptions: {
compress: {
keep_infinity: true,
// used to delete console and debugger in production environment
drop_console: VITE_DROP_CONSOLE
}
},
chunkSizeWarningLimit: 2000
},
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
optimizeDeps: {
esbuildOptions: {
plugins: [],
},
include: [
`monaco-editor/esm/vs/language/json/json.worker`,
`monaco-editor/esm/vs/language/css/css.worker`,
`monaco-editor/esm/vs/language/html/html.worker`,
`monaco-editor/esm/vs/language/typescript/ts.worker`,
`monaco-editor/esm/vs/editor/editor.worker`
],
},
}
}