-
Notifications
You must be signed in to change notification settings - Fork 21
/
vite.config.ts
44 lines (38 loc) · 1.44 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
/// <reference types="vitest" />
import type { ConfigEnv, UserConfig } from 'vite';
import { createViteBuild } from './build/vite/build';
import { createViteCSS } from './build/vite/css';
import { createViteEsbuild } from './build/vite/esbuild';
import { createViteOptimizeDeps } from './build/vite/optimizeDeps';
import { createVitePlugins } from './build/vite/plugin';
import { createViteResolve } from './build/vite/resolve';
import { createViteServer } from './build/vite/server';
import { createVitestTest } from './build/vite/viteTestConfig';
// https://vitejs.dev/config/
export default (configEnv: ConfigEnv): UserConfig => {
const { mode, command } = configEnv;
// const root = process.cwd();
// const env = loadEnv(mode, root);
const isBuild = command === 'build';
return {
// 设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息。命令行模式下请通过 --clearScreen false 设置。
clearScreen: true,
logLevel: 'info',
// esbuild
esbuild: createViteEsbuild(isBuild),
// vitest配置
test: createVitestTest(),
// 解析配置
resolve: createViteResolve(mode, __dirname),
// 插件配置
plugins: createVitePlugins(isBuild, configEnv),
// 服务配置
server: createViteServer(),
// 打包配置
build: createViteBuild(),
// 依赖优化配置
optimizeDeps: createViteOptimizeDeps(),
// css预处理配置
css: createViteCSS(),
};
};