mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 18:40:22 +08:00
1262e13067
* chore: update deps * fix: import.meta.globEager 已过期 * docs: fix doc bugs * fix: eslint * fix: lint:prettier * fix: stylelint * chore: update deps * fix: eslint * refactor: accountdetail setup * fix: 'Nullable' is not defined * feat: remove vite-plugin-vue-setup-extend * chore: remove unplugin-vue-define-options * fix(component): pageWrapper use setup closed #2898 * refactor: PageFooter use setup --------- Co-authored-by: jinmao88 <50581550+jinmao88@users.noreply.github.com>
35 lines
979 B
TypeScript
35 lines
979 B
TypeScript
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
|
|
|
|
// 问题描述
|
|
// 1. `import.meta.globEager` 已被弃用, 需要升级vite版本,有兼容问题
|
|
// 2. `vite-plugin-mock` 插件问题 https://github.com/vbenjs/vite-plugin-mock/issues/56
|
|
|
|
// const modules: Record<string, any> = import.meta.glob("./**/*.ts", {
|
|
// import: "default",
|
|
// eager: true,
|
|
// });
|
|
|
|
// const mockModules = Object.keys(modules).reduce((pre, key) => {
|
|
// if (!key.includes("/_")) {
|
|
// pre.push(...modules[key]);
|
|
// }
|
|
// return pre;
|
|
// }, [] as any[]);
|
|
|
|
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);
|
|
}
|