You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
488 B
19 lines
488 B
4 months ago
|
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
|
||
|
|
||
|
const modules = import.meta.glob('./**/*.ts', { eager: true });
|
||
|
|
||
|
const mockModules: any[] = [];
|
||
|
Object.keys(modules).forEach((key) => {
|
||
|
if (key.includes('/_')) {
|
||
|
return;
|
||
|
}
|
||
|
mockModules.push(...(modules as Recordable)[key].default);
|
||
|
});
|
||
|
|
||
|
/**
|
||
|
* Used in a production environment. Need to manually import all modules
|
||
|
*/
|
||
|
export function setupProdMockServer() {
|
||
|
createProdMockServer(mockModules);
|
||
|
}
|