lolosia-web/mock-prod-server.ts
2023-02-02 16:07:38 +08:00

13 lines
461 B
TypeScript

import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'
//https://cn.vitejs.dev/guide/features.html#glob-import
const modulesFiles = import.meta.glob('../mock/*', { eager: true })
let modules = []
for (const filePath in modulesFiles) {
//读取文件内容到 modules
modules = modules.concat(modulesFiles[filePath].default)
}
export function setupProdMockServer() {
//创建prod mock server
createProdMockServer([...modules])
}