-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mts
61 lines (61 loc) · 1.5 KB
/
vite.config.mts
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
import { defineConfig, loadEnv } from 'vite';
import { resolve } from 'path';
import { createVitePlugins } from './build/vite';
import { wrapperEnv } from './build/utils';
function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir);
}
export default defineConfig(({ mode }) => {
const root = process.cwd();
const env = loadEnv(mode, root);
const viteEnv = wrapperEnv(env);
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_DROP_CONSOLE, VITE_PROXY } = viteEnv;
return {
base: VITE_PUBLIC_PATH,
root,
server: {
port: VITE_PORT,
host: true,
proxy: {
'/api': {
target: VITE_PROXY,
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(new RegExp(`^/api`), '/'),
},
},
},
resolve: {
alias: [
{
find: 'vue-i18n',
replacement: 'vue-i18n/dist/vue-i18n.cjs.js',
},
{
find: /\/@\//,
replacement: pathResolve('src') + '/',
},
{
find: /\/#\//,
replacement: pathResolve('types') + '/',
},
],
},
esbuild: {
pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [],
},
build: {
cssTarget: 'chrome80',
chunkSizeWarningLimit: 2000,
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
additionalData: '@import "/@/styles/common/index.less";',
},
},
},
plugins: createVitePlugins(),
};
});