perf: auto import mock file

This commit is contained in:
vben 2021-01-17 23:47:54 +08:00
parent 7279c0a7b5
commit df6b5e926f

View File

@ -1,19 +1,18 @@
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
import userMock from './sys/user';
import menuMock from './sys/menu';
import tableDemoMock from './demo/table-demo';
import accountDemoMock from './demo/account';
import selectDemoMock from './demo/select-demo';
const modules = import.meta.globEager('./**/*.ts');
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([
...userMock,
...menuMock,
...tableDemoMock,
...accountDemoMock,
...selectDemoMock,
]);
createProdMockServer(mockModules);
}