mock.ts 467 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) {
  7. return viteMockServe({
  8. ignore: /^\_/,
  9. mockPath: 'mock',
  10. localEnabled: !isBuild,
  11. prodEnabled: isBuild,
  12. injectCode: `
  13. import { setupProdMockServer } from '../mock/_createProductionServer';
  14. setupProdMockServer();
  15. `,
  16. });
  17. }