Przeglądaj źródła

fix(unocss): 处理unocss在小程序中报错

Burt 2 lat temu
rodzic
commit
3c6321ad88
4 zmienionych plików z 900 dodań i 2 usunięć
  1. 7 0
      .stylelintrc.cjs
  2. 1 0
      package.json
  3. 888 0
      pnpm-lock.yaml
  4. 4 2
      uno.config.ts

+ 7 - 0
.stylelintrc.cjs

@@ -35,5 +35,12 @@ module.exports = {
         ignoreUnits: ['rpx'],
       },
     ],
+    // 处理小程序page标签不认识的问题
+    'selector-type-no-unknown': [
+      true,
+      {
+        ignoreTypes: ['page'],
+      },
+    ],
   },
 }

+ 1 - 0
package.json

@@ -91,6 +91,7 @@
     "@typescript-eslint/eslint-plugin": "^6.15.0",
     "@typescript-eslint/parser": "^6.15.0",
     "@uni-helper/uni-app-types": "^0.5.12",
+    "@uni-helper/unocss-preset-uni": "^0.2.5",
     "@vue/runtime-core": "^3.2.45",
     "@vue/tsconfig": "^0.1.3",
     "autoprefixer": "^10.4.16",

Plik diff jest za duży
+ 888 - 0
pnpm-lock.yaml


+ 4 - 2
uno.config.ts

@@ -2,15 +2,17 @@
 import {
   defineConfig,
   presetAttributify,
-  presetUno,
   presetIcons,
   transformerDirectives,
   transformerVariantGroup,
 } from 'unocss'
 
+import { presetUni } from '@uni-helper/unocss-preset-uni'
+
 export default defineConfig({
   presets: [
-    presetUno(),
+    // @ts-expect-error 类型兼容性
+    presetUni(),
     // 支持css class属性化,eg: `<button bg="blue-400 hover:blue-500 dark:blue-500 dark:hover:blue-600" text="sm white">attributify Button</button>`
     presetAttributify(),
     // 支持图标,需要搭配图标库,eg: @iconify-json/carbon, 使用 `<button class="i-carbon-sun dark:i-carbon-moon" />`