mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-23 17:50:25 +08:00
perf: auto import mock file
This commit is contained in:
parent
7279c0a7b5
commit
df6b5e926f
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user