From 4771764fdb0f77edeb2af381594aad9c274d56b1 Mon Sep 17 00:00:00 2001 From: winixt Date: Thu, 1 Jun 2023 19:51:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E5=B1=80=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/plugins/features/globalCSS.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/fes-preset-built-in/src/plugins/features/globalCSS.js b/packages/fes-preset-built-in/src/plugins/features/globalCSS.js index 1f7d6aeb..93e25a1c 100644 --- a/packages/fes-preset-built-in/src/plugins/features/globalCSS.js +++ b/packages/fes-preset-built-in/src/plugins/features/globalCSS.js @@ -2,10 +2,7 @@ import { relative, join } from 'path'; import { existsSync } from 'fs'; export default (api) => { - const { - paths, - utils: { winPath }, - } = api; + const { paths } = api; const { absSrcPath = '', absTmpPath = '' } = paths; const files = ['global.css', 'global.less', 'global.scss', 'global.sass', 'global.styl', 'global.stylus']; const globalCSSFile = files @@ -13,5 +10,10 @@ export default (api) => { .filter((file) => existsSync(file)) .slice(0, 1); - api.addEntryCodeAhead(() => `${globalCSSFile.map((file) => `import '${winPath(relative(absTmpPath, file))}';`).join('')}`); + if (globalCSSFile.length) { + api.addEntryImportsAhead({ + stage: 1, + fn: () => [{ source: relative(absTmpPath, globalCSSFile[0]) }], + }); + } };