Skip to content

Commit

Permalink
fix: 🐛 test browser template use wrong loadingComponent value (#12717)
Browse files Browse the repository at this point in the history
  • Loading branch information
stormslowly committed Sep 23, 2024
1 parent 79499d9 commit 85c2790
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/preset-umi/src/features/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { winPath } from '@umijs/utils';
import { existsSync } from 'fs';
import { dirname, join } from 'path';
import { expandJSPaths } from '../../commands/dev/watch';
import { TEMPLATES_DIR } from '../../constants';
import { IApi } from '../../types';
import { importsToStr } from '../tmpFiles/importsToStr';
Expand All @@ -27,6 +28,12 @@ export default (api: IApi) => {
),
}),
);

const loadingFile = expandJSPaths(
join(api.paths.absSrcPath, 'loading'),
).find(existsSync);
const globalLoading = loadingFile ? winPath(loadingFile) : undefined;

// testBrowser.tsx
api.writeTmpFile({
noPluginDir: true,
Expand Down Expand Up @@ -66,10 +73,7 @@ export default (api: IApi) => {
historyType: api.config.history.type,
reactRouter5Compat: !!api.config.reactRouter5Compat,
hydrate: !!api.config.ssr,
loadingComponent:
existsSync(join(api.paths.absSrcPath, 'loading.tsx')) ||
existsSync(join(api.paths.absSrcPath, 'loading.jsx')) ||
existsSync(join(api.paths.absSrcPath, 'loading.js')),
loadingComponent: globalLoading,
},
});
});
Expand Down

0 comments on commit 85c2790

Please sign in to comment.