From 54f1aa3ee2c9837e3d5f9bdf59f4a8d63ba663e1 Mon Sep 17 00:00:00 2001
From: lin yan <1466030775@qq.com>
Date: Tue, 30 Apr 2024 11:32:03 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3uno.css=E5=86=99hex?=
=?UTF-8?q?=E9=A2=9C=E8=89=B2=E7=AD=89=E5=8A=9F=E8=83=BD=E4=B8=8D=E9=AB=98?=
=?UTF-8?q?=E4=BA=AE=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
uno.config.ts | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/uno.config.ts b/uno.config.ts
index 49a1cd1..b7f4d08 100644
--- a/uno.config.ts
+++ b/uno.config.ts
@@ -1,7 +1,8 @@
// uno.config.ts
import {
- Preset,
+ type Preset,
defineConfig,
+ presetUno,
presetAttributify,
presetIcons,
transformerDirectives,
@@ -13,26 +14,23 @@ import { presetApplet, presetRemRpx, transformerAttributify } from 'unocss-apple
// @see https://unocss.dev/presets/legacy-compat
import { presetLegacyCompat } from '@unocss/preset-legacy-compat'
-const isH5 = process.env?.UNI_PLATFORM === 'h5'
const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false
const presets: Preset[] = []
-if (!isMp) {
- /**
- * you can add `presetAttributify()` here to enable unocss attributify mode prompt
- * although preset is not working for applet, but will generate useless css
- * 为了不生产无用的css,要过滤掉 applet
- */
- // 支持css class属性化,eg: ``
- presets.push(presetAttributify())
-}
-if (!isH5) {
- presets.push(presetRemRpx())
+if (isMp) {
+ // 使用小程序预设
+ presets.push(presetApplet(), presetRemRpx())
+} else {
+ presets.push(
+ // 非小程序用官方预设
+ presetUno(),
+ // 支持css class属性化
+ presetAttributify(),
+ )
}
export default defineConfig({
presets: [
...presets,
- presetApplet(),
// 支持图标,需要搭配图标库,eg: @iconify-json/carbon, 使用 ``
presetIcons({
scale: 1.2,