-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
60 lines (59 loc) · 1.61 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
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { VITE_DROP_CONSOLE, VITE_PORT } from './config/constant';
import { createVitePlugins } from './config/vite/plugins';
import { configManualChunk } from './config/vite/optimizer';
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
plugins: createVitePlugins(),
resolve: {
alias: [
{ find: /^~/, replacement: '' },
{ find: '@', replacement: '/src' }
]
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: {
hack: `true; @import (reference) "${resolve('src/assets/styles/variables.less')}";`,
},
}
}
},
server: {
hmr: { overlay: false },
// 服务配置
host: false, // host设置为true才可以使用network的形式,以ip访问项目
open: true, // 自动打开浏览器
cors: true, // 跨域设置允许
port: VITE_PORT, // 端口号
strictPort: true, // 如果端口已占用直接退出
proxy: {
'^/api': {
target: 'https://111.21.2:9090/',
changeOrigin: true,
},
},
},
build: {
target: 'es2015',
terserOptions: {
compress: {
keep_infinity: true,
drop_console: VITE_DROP_CONSOLE
}
},
rollupOptions: {
output: {
manualChunks: configManualChunk
}
},
// Turning off brotliSize display can slightly reduce packaging time
brotliSize: false,
chunkSizeWarningLimit: 2000,
},
};
});