mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-01-24 12:20:18 +08:00
17 lines
435 B
TypeScript
17 lines
435 B
TypeScript
import { createMockServer } from 'vite-plugin-mock';
|
|
import type { Plugin } from 'vite';
|
|
import { isDevFn, ViteEnv } from '../../utils';
|
|
|
|
export function setupMockPlugin(plugins: Plugin[], env: ViteEnv) {
|
|
const { VITE_USE_MOCK } = env;
|
|
const mockPlugin = createMockServer({
|
|
ignore: /^\_/,
|
|
mockPath: 'mock',
|
|
showTime: true,
|
|
});
|
|
if (isDevFn() && VITE_USE_MOCK) {
|
|
plugins.push(mockPlugin);
|
|
}
|
|
return plugins;
|
|
}
|