-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
63 lines (62 loc) · 1.52 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
61
62
63
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
// ant design vue 按需加载
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import { ModifyVar } from './conf/antdv-less-modify-var.js';
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd());
return {
base: env.VITE_BASE || '/',
plugins: [
vue(),
Components({
resolvers: [
AntDesignVueResolver({
// 样式覆盖
importStyle: 'less',
}),
],
}),
],
build: {
// 去除console
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
_comp: path.resolve(__dirname, 'src/components'),
_api: path.resolve(__dirname, 'src/api'),
_libs: path.resolve(__dirname, 'src/libs'),
},
},
css: {
preprocessorOptions: {
less: {
modifyVars: ModifyVar,
javascriptEnabled: true,
},
},
},
server: {
host: '0.0.0.0',
port: 3000,
proxy: {
'/api': {
target: env.VITE_SERVER_URL,
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
},
},
};
});