Skip to content

Commit

Permalink
fix(preset-umi): resolve the path of react-helmet-async within render
Browse files Browse the repository at this point in the history
  • Loading branch information
SK-Luffa committed Jul 11, 2024
1 parent 21fcfe4 commit 0cd1d05
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/preset-umi/src/features/vite/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let corePath: string | undefined;
const REACT_HELMET_ASYNC = 'react-helmet-async';
const RENDERER_REACT = '@umijs/renderer-react';
let pkgPath: string;
const getReactHelmetAsyncPath = (api: IApi) => {
const getReactHelmetAsyncPath = () => {
if (corePath) {
return corePath;
}
Expand All @@ -19,6 +19,7 @@ const getReactHelmetAsyncPath = (api: IApi) => {
// 解析 renderer-react 包的路径
try {
const rendererReactPath = require.resolve(RENDERER_REACT);

pkgPath = rendererReactPath ? winPath(rendererReactPath) : defaultPkgPath;
} catch (e: any) {
throw new Error(
Expand Down Expand Up @@ -58,7 +59,7 @@ export default (api: IApi) => {
api.modifyConfig((memo) => {
// like vite, use to pre-bundling dependencies in vite mode
if (isWindows) {
const corePath = getReactHelmetAsyncPath(api);
const corePath = getReactHelmetAsyncPath();
memo.alias[REACT_HELMET_ASYNC] = corePath;
}
memo.alias['@fs'] = api.cwd;
Expand Down

0 comments on commit 0cd1d05

Please sign in to comment.