_createProductionServer.ts 472 B

123456789101112131415161718
  1. import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
  2. const modules = import.meta.glob('./**/*.ts', { eager: true });
  3. const mockModules: any[] = [];
  4. Object.keys(modules).forEach((key) => {
  5. if (key.includes('/_')) {
  6. return;
  7. }
  8. mockModules.push(...modules[key].default);
  9. });
  10. /**
  11. * Used in a production environment. Need to manually import all modules
  12. */
  13. export function setupProdMockServer() {
  14. createProdMockServer(mockModules);
  15. }