MCPcopy Create free account
hub / github.com/chakra-ui/panda / pluginLightningcssWasm

Function pluginLightningcssWasm

playground/src/lib/lightningcss-plugin.ts:12–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10 * browserslistToTargets.
11 */
12export function pluginLightningcssWasm(): PandaPlugin {
13 return {
14 name: 'playground-lightningcss-wasm',
15 hooks: {
16 'css:optimize': ({ css, minify }) => {
17 try {
18 const { Features, transform } = require('lightningcss-wasm')
19
20 const encoder = new TextEncoder()
21 const decoder = new TextDecoder()
22
23 const result = transform({
24 code: encoder.encode(css),
25 minify: minify ?? false,
26 sourceMap: false,
27 filename: 'styles.css',
28 include: Features.Nesting | Features.MediaRangeSyntax,
29 errorRecovery: true,
30 })
31
32 return decoder.decode(result.code)
33 } catch {
34 // Fall through to PostCSS if wasm isn't available
35 return undefined
36 }
37 },
38 },
39 }
40}

Callers 1

usePandaContextFunction · 0.90

Calls 2

requireFunction · 0.85
transformFunction · 0.50

Tested by

no test coverage detected