index.ts 446 B

123456789101112131415
  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('/_')) return
  6. if (key.includes('/index.ts')) return
  7. const module: any = modules[key]
  8. mockModules.push(...module.default)
  9. })
  10. export const setupProdMockServer = () => {
  11. createProdMockServer(mockModules)
  12. }