-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
52 lines (50 loc) · 1.29 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
import { resolve } from 'path'
import { defineConfig, loadEnv } from 'vite'
import vue2 from '@vitejs/plugin-vue2'
export default ({ mode }) => {
const { VITE_PORT, VITE_BASE_URL } = loadEnv(mode, process.cwd())
return defineConfig({
base: VITE_BASE_URL,
plugins: [vue2()],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import (reference) "${resolve('src/style/variables.scss')}";`,
},
math: 'strict',
javascriptEnabled: true,
},
},
},
server: {
// 是否开启 https
https: false,
// 端口号
port: VITE_PORT,
// 监听所有地址
host: '0.0.0.0',
// 服务启动时是否自动打开浏览器
open: true,
// 允许跨域
cors: true,
// 自定义代理规则
proxy: {},
},
build: {
// 设置最终构建的浏览器兼容目标
target: 'es2015',
// 构建后是否生成 source map 文件
sourcemap: false,
// chunk 大小警告的限制(以 kbs 为单位)
chunkSizeWarningLimit: 2000,
// 启用/禁用 gzip 压缩大小报告
reportCompressedSize: false,
},
})
}