Skip to content

Commit 8e4e932

Browse files
easymikeyМихаил Авдеев
and
Михаил Авдеев
authoredMay 27, 2024··
fix(css): handle lightningcss compiled css in Deno (#17301)
Co-authored-by: Михаил Авдеев <mikhail.avdeev@vk.team>
1 parent 4a89766 commit 8e4e932

File tree

1 file changed

+5
-1
lines changed
  • packages/vite/src/node/plugins

1 file changed

+5
-1
lines changed
 

‎packages/vite/src/node/plugins/css.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2695,6 +2695,7 @@ function isPreProcessor(lang: any): lang is PreprocessLang {
26952695

26962696
const importLightningCSS = createCachedImport(() => import('lightningcss'))
26972697

2698+
const decoder = new TextDecoder()
26982699
async function compileLightningCSS(
26992700
id: string,
27002701
src: string,
@@ -2760,7 +2761,10 @@ async function compileLightningCSS(
27602761
: undefined,
27612762
})
27622763

2763-
let css = res.code.toString()
2764+
// NodeJS res.code = Buffer
2765+
// Deno res.code = Uint8Array
2766+
// For correct decode compiled css need to use TextDecoder
2767+
let css = decoder.decode(res.code)
27642768
for (const dep of res.dependencies!) {
27652769
switch (dep.type) {
27662770
case 'url':

0 commit comments

Comments
 (0)
Please sign in to comment.