-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
vite.config.ts
49 lines (45 loc) · 1.03 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
import { defineConfig } from 'vite';
import type { UserConfig } from 'vite';
import { deepMix } from '@antv/util';
const { LINK, MODULE } = process.env;
if (LINK === '1' && !MODULE) {
throw new Error(
`Please specify MODULE, for example: $ MODULE=@antv/component npm run dev:link.`,
);
}
/**
* @desc Deeply merge user config into default config
* @link https://vitejs.dev/config/
* @type {import('vite').UserConfig}
*/
const baseOptions: UserConfig = {
root: './__tests__/',
server: {
port: 8080,
open: '/',
},
build: { outDir: '../' },
};
/**
* @desc Link configuration
* @link https://vitejs.dev/config/
* @type {import('vite').UserConfig}
*/
const linkOptions: UserConfig = {
server: {
watch: {
ignored: [`!**/node_modules/${MODULE}/**`],
},
},
optimizeDeps: {
exclude: [`${MODULE}`],
},
};
/**
* @desc Vite configuration
* @link https://vitejs.dev/config/
* @type {import('vite').UserConfig}
*/
export default defineConfig(
deepMix(baseOptions, LINK === '1' ? linkOptions : {}),
);