pref: improve unocss perf

zio/stable
Anthony Fu 2023-07-29 01:29:15 +08:00
parent 468a17ad58
commit 28f9540113
1 changed files with 24 additions and 16 deletions

View File

@ -1,3 +1,4 @@
import type { Variant } from 'unocss'
import { import {
defineConfig, defineConfig,
presetAttributify, presetAttributify,
@ -106,22 +107,29 @@ export default defineConfig({
}, },
}, },
variants: [ variants: [
(matcher) => { ...(process.env.TAURI_PLATFORM
if (!process.env.TAURI_PLATFORM || !matcher.startsWith('native:')) ? <Variant<any>[]>[(matcher) => {
return matcher if (!matcher.startsWith('native:'))
return
return { return {
matcher: matcher.slice(7), matcher: matcher.slice(7),
layer: 'native', layer: 'native',
} }
}, }]
: []),
...(process.env.TAURI_PLATFORM !== 'macos'
? <Variant<any>[]>[
(matcher) => { (matcher) => {
if (process.env.TAURI_PLATFORM !== 'macos' || !matcher.startsWith('native-mac:')) if (!matcher.startsWith('native-mac:'))
return matcher return
return { return {
matcher: matcher.slice(11), matcher: matcher.slice(11),
layer: 'native-mac', layer: 'native-mac',
} }
}, },
]
: []
),
variantParentMatcher('fullscreen', '@media (display-mode: fullscreen)'), variantParentMatcher('fullscreen', '@media (display-mode: fullscreen)'),
variantParentMatcher('coarse-pointer', '@media (pointer: coarse)'), variantParentMatcher('coarse-pointer', '@media (pointer: coarse)'),
], ],