-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
71 lines (68 loc) · 1.73 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
/*
* @Author: HxB
* @Date: 2022-05-05 16:49:53
* @LastEditors: DoubleAm
* @LastEditTime: 2022-08-23 18:25:01
* @Description: vite 配置文件
* @FilePath: \vue-admin\vite.config.ts
*/
import path from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import eslint from 'vite-plugin-eslint';
// import.meta.env.VITE_REQUEST_BASE_URL
// eslint-disable-next-line no-undef
const getPath = (_path) => path.resolve(__dirname, _path);
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
return {
// envPrefix: 'VITE_', // 以 envPrefix 开头的环境变量会通过 import.meta.env 暴露在你的客户端源码中。 default: 'VITE_'
base: './', // https://vitejs.cn/config/#base 公共基础路径
build: {
chunkSizeWarningLimit: 2048,
target: 'modules',
outDir: 'dist',
assetsDir: 'assets',
minify: 'terser',
terserOptions: {
// 生产环境去除 console
compress: {
drop_console: true,
drop_debugger: true,
},
},
},
publicDir: getPath('public'), // 静态资源服务的文件夹
plugins: [
eslint({
fix: true,
}),
vue(),
vueJsx(),
],
resolve: {
alias: {
'@': getPath('src'),
},
},
preview: {
port: 9868,
},
server: {
cors: true,
open: true,
hmr: true,
host: true,
port: 3000,
proxy: {
'/api': {
target: 'http://a.biugle.cn/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
};
// https://antdv.com/docs/vue/customize-theme-cn
});