_createProductionServer.ts 418 B

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