Skip to content

Commit

Permalink
fix: mock import
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan32 committed Aug 16, 2024
1 parent 3bdaf40 commit 3515878
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions mock/_createProductionServer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { createProdMockServer } from 'vite-plugin-mock/dist/client';
import { createProdMockServer } from 'vite-plugin-mock/client';

const modules: Record<string, any> = import.meta.glob('./**/*.ts', {
import: 'default',
eager: true,
});
const modules = import.meta.glob('./**/*.ts', { eager: true });

const mockModules = Object.keys(modules).reduce((pre, key) => {
if (!key.includes('/_')) {
pre.push(...modules[key]);
const mockModules: any[] = [];
Object.keys(modules).forEach((key) => {
if (key.includes('/_')) {
return;
}
return pre;
}, [] as any[]);
mockModules.push(...(modules as Recordable)[key].default);
});

/**
* Used in a production environment. Need to manually import all modules
Expand Down

0 comments on commit 3515878

Please sign in to comment.