vue3-vant4-mobile/mock/_createProductionServer.ts
xiangshu233 a1ccac5b41 fix: 🔨 修复线上 Mock 报错的问题
docs: 📔 README 新增线上预览
2022-10-23 17:17:07 +08:00

19 lines
479 B
TypeScript

import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
const modules = import.meta.glob('./**/*.ts', { eager: true }) as any;
const mockModules: any[] = [];
Object.keys(modules).forEach((key) => {
if (key.includes('/_')) {
return;
}
mockModules.push(...modules[key].default);
});
/**
* Used in a production environment. Need to manually import all modules
*/
export function setupProdMockServer() {
createProdMockServer(mockModules);
}