Skip to content

Commit b3f5bd1

Browse files
authored
fix(css): handle lightningcss minification in Deno (#17372)
1 parent 6fbb5e0 commit b3f5bd1

File tree

1 file changed

+6
-3
lines changed
  • packages/vite/src/node/plugins

1 file changed

+6
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import {
8383
import type { ESBuildOptions } from './esbuild'
8484
import { getChunkOriginalFileName } from './manifest'
8585

86+
const decoder = new TextDecoder()
8687
// const debug = createDebugger('vite:css')
8788

8889
export interface CSSOptions {
@@ -1808,8 +1809,12 @@ async function minifyCSS(
18081809
),
18091810
)
18101811
}
1812+
1813+
// NodeJS res.code = Buffer
1814+
// Deno res.code = Uint8Array
1815+
// For correct decode compiled css need to use TextDecoder
18111816
// LightningCSS output does not return a linebreak at the end
1812-
return code.toString() + (inlined ? '' : '\n')
1817+
return decoder.decode(code) + (inlined ? '' : '\n')
18131818
}
18141819
try {
18151820
const { code, warnings } = await transform(css, {
@@ -2698,8 +2703,6 @@ function isPreProcessor(lang: any): lang is PreprocessLang {
26982703
}
26992704

27002705
const importLightningCSS = createCachedImport(() => import('lightningcss'))
2701-
2702-
const decoder = new TextDecoder()
27032706
async function compileLightningCSS(
27042707
id: string,
27052708
src: string,

0 commit comments

Comments
 (0)