Skip to content

Commit

Permalink
fix(css): handle lightningcss compiled css in Deno (#17301)
Browse files Browse the repository at this point in the history
Co-authored-by: Михаил Авдеев <[email protected]>
  • Loading branch information
easymikey and Михаил Авдеев authored May 27, 2024
1 parent 4a89766 commit 8e4e932
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 8e4e932

Please sign in to comment.