vben
authored
|
1
2
|
import { viteMockServe } from 'vite-plugin-mock';
import { ViteEnv } from '../../utils';
|
vben
authored
|
3
|
|
vben
authored
|
4
|
export function configMockPlugin(env: ViteEnv, isBuild: boolean) {
|
vben
authored
|
5
|
const { VITE_USE_MOCK } = env;
|
vben
authored
|
6
|
|
vben
authored
|
7
|
const useMock = !isBuild && VITE_USE_MOCK;
|
vben
authored
|
8
9
|
if (useMock) {
|
vben
authored
|
10
|
const mockPlugin = viteMockServe({
|
vben
authored
|
11
12
13
14
15
|
ignore: /^\_/,
mockPath: 'mock',
showTime: true,
localEnabled: useMock,
});
|
vben
authored
|
16
|
return mockPlugin;
|
vben
authored
|
17
|
}
|
vben
authored
|
18
|
return [];
|
vben
authored
|
19
|
}
|