From 28f95401131f898937b3d768d5ba3e49d23c0e1c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 29 Jul 2023 01:29:15 +0800 Subject: [PATCH] pref: improve unocss perf --- unocss.config.ts | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/unocss.config.ts b/unocss.config.ts index 1e543b4a..46a01c19 100644 --- a/unocss.config.ts +++ b/unocss.config.ts @@ -1,3 +1,4 @@ +import type { Variant } from 'unocss' import { defineConfig, presetAttributify, @@ -106,22 +107,29 @@ export default defineConfig({ }, }, variants: [ - (matcher) => { - if (!process.env.TAURI_PLATFORM || !matcher.startsWith('native:')) - return matcher - return { - matcher: matcher.slice(7), - layer: 'native', - } - }, - (matcher) => { - if (process.env.TAURI_PLATFORM !== 'macos' || !matcher.startsWith('native-mac:')) - return matcher - return { - matcher: matcher.slice(11), - layer: 'native-mac', - } - }, + ...(process.env.TAURI_PLATFORM + ? []>[(matcher) => { + if (!matcher.startsWith('native:')) + return + return { + matcher: matcher.slice(7), + layer: 'native', + } + }] + : []), + ...(process.env.TAURI_PLATFORM !== 'macos' + ? []>[ + (matcher) => { + if (!matcher.startsWith('native-mac:')) + return + return { + matcher: matcher.slice(11), + layer: 'native-mac', + } + }, + ] + : [] + ), variantParentMatcher('fullscreen', '@media (display-mode: fullscreen)'), variantParentMatcher('coarse-pointer', '@media (pointer: coarse)'), ],