From 44006b5ee9b573fefe80c9268d5f3a161ccdfcc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8E=E5=A3=B0?= Date: Thu, 28 Mar 2024 14:14:30 +0800 Subject: [PATCH] feat: skip bundle stats page when load js --- .../src/features/devTool/devTool.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/preset-umi/src/features/devTool/devTool.ts b/packages/preset-umi/src/features/devTool/devTool.ts index 1cab8ccf360e..ef3c503e7ab6 100644 --- a/packages/preset-umi/src/features/devTool/devTool.ts +++ b/packages/preset-umi/src/features/devTool/devTool.ts @@ -80,17 +80,21 @@ export default (api: IApi) => { } } - // bundle status - const isDone = - api.appData.bundleStatus.done && - (enableVite || - api.config.mfsu === false || - api.appData.mfsuBundleStatus.done); - - if (!isDone) { - res.setHeader('Content-Type', 'text/html'); - res.send(loadingHtml); - return; + if ( + req.headers.accept?.includes('text/html') || + req.headers.accept === '*/*' + ) { + // bundle status + const isDone = + api.appData.bundleStatus.done && + (enableVite || + api.config.mfsu === false || + api.appData.mfsuBundleStatus.done); + if (!isDone) { + res.setHeader('Content-Type', 'text/html'); + res.send(loadingHtml); + return; + } } return next();