Skip to content

Commit

Permalink
fix(css): handle lightningcss minification in Deno (#17372)
Browse files Browse the repository at this point in the history
  • Loading branch information
easymikey authored Jun 3, 2024
1 parent 6fbb5e0 commit b3f5bd1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import {
import type { ESBuildOptions } from './esbuild'
import { getChunkOriginalFileName } from './manifest'

const decoder = new TextDecoder()
// const debug = createDebugger('vite:css')

export interface CSSOptions {
Expand Down Expand Up @@ -1808,8 +1809,12 @@ async function minifyCSS(
),
)
}

// NodeJS res.code = Buffer
// Deno res.code = Uint8Array
// For correct decode compiled css need to use TextDecoder
// LightningCSS output does not return a linebreak at the end
return code.toString() + (inlined ? '' : '\n')
return decoder.decode(code) + (inlined ? '' : '\n')
}
try {
const { code, warnings } = await transform(css, {
Expand Down Expand Up @@ -2698,8 +2703,6 @@ 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

0 comments on commit b3f5bd1

Please sign in to comment.