basic2/vite/plugins/mock.ts

15 lines
381 B
TypeScript
Raw Normal View History

2022-09-26 00:21:50 +08:00
import { viteMockServe } from 'vite-plugin-mock'
export default function createMock(env, isBuild) {
const { VITE_BUILD_MOCK } = env
return viteMockServe({
mockPath: 'src/mock',
localEnabled: !isBuild,
prodEnabled: isBuild && VITE_BUILD_MOCK === 'true',
injectCode: `
import { setupProdMockServer } from './mockProdServer';
setupProdMockServer();
`,
})
}