From 36db6ed4ce6fa64a1a1c0963719df1b774cbe9a2 Mon Sep 17 00:00:00 2001 From: Siriwat K Date: Tue, 13 Feb 2024 17:28:08 +0700 Subject: [PATCH] [zero] Fix wrong CSS order by moving import to last (#41002) --- packages/zero-unplugin/src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/zero-unplugin/src/index.ts b/packages/zero-unplugin/src/index.ts index 8fbecbab554766..ab21cb71d0f4d2 100644 --- a/packages/zero-unplugin/src/index.ts +++ b/packages/zero-unplugin/src/index.ts @@ -225,7 +225,8 @@ export const plugin = createUnplugin((options) => { }), )}`; return { - code: `import ${JSON.stringify(data)};\n${result.code}`, + // CSS import should be the last so that nested components produce correct CSS order injection. + code: `${result.code}\nimport ${JSON.stringify(data)};`, map: result.sourceMap, }; } @@ -233,7 +234,7 @@ export const plugin = createUnplugin((options) => { cssFileLookup.set(cssId, cssFilename); cssLookup.set(cssFilename, cssText); return { - code: `import ${JSON.stringify(`./${cssFilename}`)};\n${result.code}`, + code: `${result.code}\nimport ${JSON.stringify(`./${cssFilename}`)};`, map: result.sourceMap, }; } catch (e) {