From 8e4e932b4979bc40a03b0ffb65b960df62226def Mon Sep 17 00:00:00 2001 From: Mikhail Avdeev <39246971+easymikey@users.noreply.github.com> Date: Mon, 27 May 2024 17:33:47 +0300 Subject: [PATCH] fix(css): handle lightningcss compiled css in Deno (#17301) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Михаил Авдеев --- packages/vite/src/node/plugins/css.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 08c5708de86874..4fd0bdf7f1f044 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -2695,6 +2695,7 @@ function isPreProcessor(lang: any): lang is PreprocessLang { const importLightningCSS = createCachedImport(() => import('lightningcss')) +const decoder = new TextDecoder() async function compileLightningCSS( id: string, src: string, @@ -2760,7 +2761,10 @@ async function compileLightningCSS( : undefined, }) - let css = res.code.toString() + // NodeJS res.code = Buffer + // Deno res.code = Uint8Array + // For correct decode compiled css need to use TextDecoder + let css = decoder.decode(res.code) for (const dep of res.dependencies!) { switch (dep.type) { case 'url':