mock.ts 502 B

12345678910111213141516171819
  1. /**
  2. * Mock plugin for development and production.
  3. * https://github.com/anncwb/vite-plugin-mock
  4. */
  5. import { viteMockServe } from 'vite-plugin-mock';
  6. export function configMockPlugin(isBuild: boolean, prodMock: boolean) {
  7. return viteMockServe({
  8. ignore: /^\_/,
  9. mockPath: 'mock',
  10. localEnabled: !isBuild,
  11. prodEnabled: isBuild && prodMock,
  12. injectCode: `
  13. import { setupProdMockServer } from '../mock/_createProductionServer';
  14. setupProdMockServer();
  15. `,
  16. });
  17. }