diff --git a/packages/preset-umi/src/features/tmpFiles/__snapshots__/routes.test.ts.snap b/packages/preset-umi/src/features/tmpFiles/__snapshots__/routes.test.ts.snap index f31ab53f2133..fa1dcdeecfc3 100644 --- a/packages/preset-umi/src/features/tmpFiles/__snapshots__/routes.test.ts.snap +++ b/packages/preset-umi/src/features/tmpFiles/__snapshots__/routes.test.ts.snap @@ -57,8 +57,6 @@ exports[`getRoutes 1`] = ` "path": "/absolute", }, "@@/global-layout": { - "__content": "", - "__isJSFile": true, "absPath": "/", "file": "@/layouts/index.tsx", "id": "@@/global-layout", diff --git a/packages/preset-umi/src/features/tmpFiles/routes.ts b/packages/preset-umi/src/features/tmpFiles/routes.ts index 9d2e01f5b99d..8942f0c60ef0 100644 --- a/packages/preset-umi/src/features/tmpFiles/routes.ts +++ b/packages/preset-umi/src/features/tmpFiles/routes.ts @@ -144,9 +144,12 @@ export async function getRoutes(opts: { } const isJSFile = /.[jt]sx?$/.test(file); - routes[id].__content = readFileSync(file, 'utf-8'); + // layout route 这里不需要这些属性 + if (!routes[id].isLayout) { + routes[id].__content = readFileSync(file, 'utf-8'); + routes[id].__isJSFile = isJSFile; + } routes[id].__absFile = winPath(file); - routes[id].__isJSFile = isJSFile; const enableSSR = opts.api.config.ssr; const enableClientLoader = opts.api.config.clientLoader;