-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.config.ts
64 lines (58 loc) · 1.71 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, loadEnv } from 'vite';
import process from 'node:process';
import { fileURLToPath, URL } from 'node:url';
import { getEnvConfig } from './.env.config';
import {
createViteBuild,
createVitePlugins,
createViteProxy,
} from './build/vite';
import { getBuildTime } from './build/utils';
// crypto-js 默认使用4.1.1,最新版打包以后报错
// unocss默认使用0.58.5,最新版改成ejs了,需要手动改回0.58.5
// https://vitejs.dev/config/
export default defineConfig((configEnv) => {
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as ImportMetaEnv;
const { VITE_HTTP_PROXY = false, VITE_BASE_URL, VITE_PORT } = viteEnv;
const envConfig = getEnvConfig(viteEnv);
const buildTime = getBuildTime();
return {
base: VITE_BASE_URL,
resolve: {
alias: {
'~': fileURLToPath(new URL('./', import.meta.url)),
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
plugins: createVitePlugins(
viteEnv,
configEnv.command === 'build',
buildTime,
),
define: {
BUILD_TIME: JSON.stringify(buildTime),
},
server: {
host: '0.0.0.0',
port: VITE_PORT || 3200,
open: true,
proxy: createViteProxy(VITE_HTTP_PROXY, envConfig),
},
optimizeDeps: {
exclude: ['crypto-js'],
},
build: createViteBuild(viteEnv),
// 需要引入arco全局样式
// css: {
// preprocessorOptions: {
// less: {
// modifyVars: {
// 'color-menu-dark-bg': '#001428',
// // hack: `true; @import (reference) "${resolve('src/styles/config.less')}";`,
// },
// javascriptEnabled: true,
// },
// },
// },
};
});