{"id":13691905,"url":"https://github.com/unocss-applet/unocss-applet","last_synced_at":"2025-04-06T01:05:58.743Z","repository":{"id":56788218,"uuid":"524644676","full_name":"unocss-applet/unocss-applet","owner":"unocss-applet","description":"Using UnoCSS in applet(UniApp / Taro) to be compatible with unsupported syntax. 在小程序中使用UnoCSS，兼容不支持的语法。","archived":false,"fork":false,"pushed_at":"2024-04-12T14:51:20.000Z","size":1580,"stargazers_count":147,"open_issues_count":6,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-12T21:14:59.958Z","etag":null,"topics":["applet","miniprogram","taro","uniapp","unocss","unocss-preset"],"latest_commit_sha":null,"homepage":"https://unocss-applet.netlify.app","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unocss-applet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-14T10:57:10.000Z","updated_at":"2024-05-02T12:00:23.315Z","dependencies_parsed_at":"2024-04-12T14:58:19.982Z","dependency_job_id":null,"html_url":"https://github.com/unocss-applet/unocss-applet","commit_stats":{"total_commits":109,"total_committers":2,"mean_commits":54.5,"dds":0.00917431192660545,"last_synced_commit":"218e0a9556d05b3940418ae44f04d1ebd696e41b"},"previous_names":[],"tags_count":78,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unocss-applet%2Funocss-applet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unocss-applet%2Funocss-applet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unocss-applet%2Funocss-applet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unocss-applet%2Funocss-applet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unocss-applet","download_url":"https://codeload.github.com/unocss-applet/unocss-applet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419859,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["applet","miniprogram","taro","uniapp","unocss","unocss-preset"],"created_at":"2024-08-02T17:00:51.495Z","updated_at":"2025-04-06T01:05:58.720Z","avatar_url":"https://github.com/unocss-applet.png","language":"CSS","funding_links":[],"categories":["Community","Presets","Lib 工具库"],"sub_categories":["Presets"],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/unocss-applet/unocss-applet/raw/main/public/logo.svg\" style=\"width:100px;\" /\u003e\n\u003ch1 align=\"center\"\u003eUnoCSS Applet\u003c/h1\u003e\n\u003cp align=\"center\"\u003eUsing \u003ca href=\"https://github.com/unocss/unocss\"\u003eUnoCSS\u003c/a\u003e in applet(for \u003ca href=\"https://github.com/dcloudio/uni-app\"\u003eUniApp\u003c/a\u003e and \u003ca href=\"https://github.com/NervJS/taro\"\u003eTaro\u003c/a\u003e) to be compatible with unsupported syntax.\u003c/p\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/unocss-applet\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/unocss-applet?style=flat\u0026colorA=858585\u0026colorB=F17F42\" alt=\"NPM version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/unocss-applet\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/unocss-applet?style=flat\u0026colorA=858585\u0026colorB=F17F42\" alt=\"NPM Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://bundlephobia.com/result?p=unocss-applet\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/minzip/unocss-applet?style=flat\u0026colorA=858585\u0026colorB=F17F42\" alt=\"Bundle\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/unocss-applet/unocss-applet/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/unocss-applet/unocss-applet.svg?style=flat\u0026colorA=858585\u0026colorB=F17F42\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align='center'\u003e\n\u003cb\u003eEnglish\u003c/b\u003e | \u003ca href=\"https://github.com/unocss-applet/unocss-applet/blob/main/README.zh-CN.md\"\u003e简体中文\u003c/a\u003e\n\u003c/p\u003e\n\n## Presets and Plugins\n\n- [unocss-applet](https://github.com/unocss-applet/unocss-applet/tree/main/packages/unocss-applet) - The default package with common presets and plugins.\n- [@unocss-applet/preset-applet](https://github.com/unocss-applet/unocss-applet/tree/main/packages/preset-applet) - The default preset (right now it's equivalent to `@unocss/preset-uno`).\n- [@unocss-applet/preset-rem-rpx](https://github.com/unocss-applet/unocss-applet/tree/main/packages/preset-rem-rpx) - Coverts rem \u003c=\u003e rpx for utils.\n- [@unocss-applet/transformer-attributify](https://github.com/unocss-applet/unocss-applet/tree/main/packages/transformer-attributify) - Enables Attributify Mode for applet.\n- [@unocss-applet/reset](https://github.com/unocss-applet/unocss-applet/tree/main/packages/reset) - Collection of reset CSS stylesheets.\n\n## Installation\n\n```bash\nnpm i unocss-applet --save-dev # with npm\nyarn add unocss-applet -D # with yarn\npnpm add unocss-applet -D # with pnpm\n```\n\n## Usage\n\n### UnoCSS config\n\n\u003cdetails\u003e\n\u003csummary\u003euno.config.ts\u003c/summary\u003e\u003cbr\u003e\n\n```ts\nimport type { Preset, SourceCodeTransformer } from 'unocss'\nimport { defineConfig } from 'unocss'\n\nimport {\n  presetApplet,\n  presetRemRpx,\n  transformerAttributify,\n} from 'unocss-applet'\n\n// uni-app\nconst isApplet = process.env?.UNI_PLATFORM?.startsWith('mp-') ?? false\n// taro\n// const isApplet = process.env.TARO_ENV !== 'h5' ?? false\nconst presets: Preset[] = []\nconst transformers: SourceCodeTransformer[] = []\n\nif (isApplet) {\n  presets.push(presetApplet())\n  presets.push(presetRemRpx())\n  transformers.push(transformerAttributify({ ignoreAttributes: ['block'] }))\n}\nelse {\n  presets.push(presetApplet())\n  presets.push(presetAttributify())\n  presets.push(presetRemRpx({ mode: 'rpx2rem' }))\n}\n\nexport default defineConfig({\n  presets: [\n    // ...\n    ...presets,\n  ],\n  transformers: [\n    // ...\n    ...transformers,\n  ],\n})\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n### For Platform\n\n\u003cdetails\u003e\n\u003csummary\u003eUniApp + Vue3 + Vite\u003c/summary\u003e\u003cbr\u003e\n\n`vite.config.ts` (UnoCSS v0.58 or below) / `vite.config.mts` (UnoCSS v0.59 or above)\n\n```ts\nimport uniModule from '@dcloudio/vite-plugin-uni'\nimport UnoCSS from 'unocss/vite'\nimport { defineConfig } from 'vite'\n\n// @ts-expect-error missing types\nconst Uni = uniModule.default || uniModule\n\nexport default defineConfig({\n  plugins: [\n    Uni(),\n    UnoCSS(),\n  ],\n})\n```\n\n`main.ts`\n\n```ts\nimport 'uno.css'\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eTaro v3.6 + Vue3 + Webpack5\u003c/summary\u003e\u003cbr\u003e\n\n`config/index.js` (UnoCSS v0.59 or above)\n\n```js\nimport { createSwcRegister, getModuleDefaultExport } from '@tarojs/helper'\n\nexport default async () =\u003e {\n  createSwcRegister({\n    only: [filePath =\u003e filePath.includes('@unocss')],\n  })\n  const UnoCSS = getModuleDefaultExport(await import('@unocss/webpack'))\n  return {\n    mini: {\n      // ...\n      webpackChain(chain, _webpack) {\n        chain.plugin('unocss').use(UnoCSS())\n      }\n    },\n    h5: {\n      // ...\n      webpackChain(chain) {\n        chain.plugin('unocss').use(UnoCSS())\n      }\n    }\n  }\n}\n```\n\n`config/index.js` (UnoCSS v0.58 or below)\n\n```js\nimport UnoCSS from 'unocss/webpack'\n\nconst config = {\n  mini: {\n    // ...\n    webpackChain(chain, _webpack) {\n      chain.plugin('unocss').use(UnoCSS())\n    },\n  },\n  h5: {\n    // ...\n    webpackChain(chain, _webpack) {\n      chain.plugin('unocss').use(UnoCSS())\n    },\n  },\n}\n```\n\n`app.ts`\n\n```ts\nimport 'uno.css'\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n## Example\n\n- [starter-uni](https://github.com/nei1ee/starter-uni)\n- [ColorTimetable](https://github.com/nei1ee/ColorTimetable)\n\n## Acknowledgement\n\n- [UnoCSS](https://github.com/unocss/unocss)\n\n## License\n\nMIT License \u0026copy; 2022-PRESENT [Neil](https://github.com/nei1ee) and all contributors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funocss-applet%2Funocss-applet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funocss-applet%2Funocss-applet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funocss-applet%2Funocss-applet/lists"}