Skip to content

Commit

Permalink
fix(vite): map vfsLayers to unocss layers (#2831)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeyzhao19 committed Jul 8, 2023
1 parent 2277364 commit 5d70124
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/modes/global/build.ts
Expand Up @@ -210,11 +210,12 @@ export function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>
return null
}
const result = await generateAll()
const mappedVfsLayer = Array.from(vfsLayers).map(layer => layer === LAYER_MARK_ALL ? layer : layer.replace(/^_/, ''))
const cssWithLayers = Array.from(vfsLayers).map(layer =>
`#--unocss-layer-start--${layer}--{start:${layer}} ${
layer === LAYER_MARK_ALL
? result.getLayers(undefined, Array.from(vfsLayers))
: (result.getLayer(layer) || '')
? result.getLayers(undefined, mappedVfsLayer)
: (result.getLayer(layer.replace(/^_/, '')) || '')
} #--unocss-layer-end--${layer}--{end:${layer}}`,
).join('')

Expand Down

0 comments on commit 5d70124

Please sign in to comment.