2020-09-28 20:19:10 +08:00
|
|
|
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
|
2021-01-17 23:47:54 +08:00
|
|
|
|
|
|
|
const modules = import.meta.globEager('./**/*.ts');
|
|
|
|
|
|
|
|
const mockModules: any[] = [];
|
|
|
|
Object.keys(modules).forEach((key) => {
|
|
|
|
if (key.includes('/_')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mockModules.push(...modules[key].default);
|
|
|
|
});
|
2020-09-28 20:19:10 +08:00
|
|
|
|
2020-10-29 23:01:11 +08:00
|
|
|
/**
|
|
|
|
* Used in a production environment. Need to manually import all modules
|
|
|
|
*/
|
2020-09-28 20:19:10 +08:00
|
|
|
export function setupProdMockServer() {
|
2021-01-17 23:47:54 +08:00
|
|
|
createProdMockServer(mockModules);
|
2020-09-28 20:19:10 +08:00
|
|
|
}
|