fix: 解决uno.css写hex颜色等功能不高亮问题

This commit is contained in:
lin yan 2024-04-30 11:32:03 +08:00
parent 7a90f2f57b
commit 54f1aa3ee2

View File

@ -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: `<button bg="blue-400 hover:blue-500 dark:blue-500 dark:hover:blue-600" text="sm white">attributify Button</button>`
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, 使用 `<button class="i-carbon-sun dark:i-carbon-moon" />`
presetIcons({
scale: 1.2,