-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
64 lines (63 loc) · 1.6 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
import { defineConfig, normalizePath, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import viteEslint from 'vite-plugin-eslint'
import tsconfigPaths from 'vite-tsconfig-paths'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
return {
build: {
sourcemap: !(env.VITE_ENV_NAME === 'production'),
minify: 'terser',
terserOptions: {
compress: {
//生产环境时移除debugger
drop_debugger: true
}
}
},
define: {
'process.env': process.env
},
plugins: [react(), viteEslint({ failOnError: false }), tsconfigPaths()],
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, 'src')
},
{
find: 'styles',
replacement: path.resolve(__dirname, 'src/styles')
}
]
},
// css 相关的配置
css: {
modules: {
generateScopedName: '[name]__[local]___[hash:base64:5]'
},
// LESS, 这里是 LESS 的配置可以忽略
preprocessorOptions: {
less: {
javascriptEnabled: true,
charset: false,
globalVars: {
// 配置Less的全局变量
// blue:"#1CC0FF"
}
}
}
},
server: {
host: true,
proxy: {
'/api': {
target: 'http://xxx.xxx.com', // 设置你调用的接口域名和端口号 别忘了加http
changeOrigin: true // needed for virtual hosted sites
}
}
}
}
})