{"id":32429392,"url":"https://github.com/mellowco/unocss-webpack-uniapp2","last_synced_at":"2025-10-25T20:52:28.538Z","repository":{"id":52112838,"uuid":"517289629","full_name":"MellowCo/unocss-webpack-uniapp2","owner":"MellowCo","description":"uniapp vue2 的unocss webpack插件","archived":false,"fork":false,"pushed_at":"2023-08-01T07:14:18.000Z","size":11085,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-27T23:16:37.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/unocss-webpack-uniapp2","language":"TypeScript","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/MellowCo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-24T10:17:19.000Z","updated_at":"2025-07-09T23:35:46.000Z","dependencies_parsed_at":"2022-09-04T19:02:18.148Z","dependency_job_id":null,"html_url":"https://github.com/MellowCo/unocss-webpack-uniapp2","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/MellowCo/unocss-webpack-uniapp2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellowCo%2Funocss-webpack-uniapp2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellowCo%2Funocss-webpack-uniapp2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellowCo%2Funocss-webpack-uniapp2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellowCo%2Funocss-webpack-uniapp2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MellowCo","download_url":"https://codeload.github.com/MellowCo/unocss-webpack-uniapp2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellowCo%2Funocss-webpack-uniapp2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281019446,"owners_count":26430647,"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","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-25T20:52:08.600Z","updated_at":"2025-10-25T20:52:28.532Z","avatar_url":"https://github.com/MellowCo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unocss-webpack-uniapp2\n\n[UnoCSS](https://github.com/unocss/unocss) Webpack plugin for UniApp2, fork form [@unocss/webpack](https://github.com/unocss/unocss/tree/main/packages/webpack)\n\n## 示例app\n[unocss-webpack-uniapp2.apk](https://raw.githubusercontent.com/MellowCo/unocss-webpack-uniapp2/main/unocss-webpack-uniapp2.apk)\n\n![](https://fastly.jsdelivr.net/gh/MellowCo/image-host/2022/202208071542409.png)\n\n\n## 解决问题\n\n\u003e  小程序项目启动时 部分class生成失败 需要手动触发\n\n![image-20220724191023247](https://fastly.jsdelivr.net/gh/MellowCo/image-host/2022/202207241910381.png)\n\n\n\n---\n\n\u003e  `uniapp vue2` **app** 无法使用 `import 'uno.css'`\n\n\u003cimg src=\"https://fastly.jsdelivr.net/gh/MellowCo/image-host/2022/202207242000978.png\" alt=\"image-20220724200055889\" style=\"zoom:50%;\" /\u003e\n\n## 使用\n\n[具体使用 demo](https://github.com/MellowCo/unocss-preset-weapp#uniapp-vue2)\n\n\n---\n1. vue.config.js\n\n```js\nconst UnoCSS = require('unocss-webpack-uniapp2').default\n\nmodule.exports = {\n  configureWebpack: {\n    plugins: [\n      UnoCSS(),\n    ],\n  },\n}\n```\n\n2. unocss.config.js\n```js\nimport presetWeapp from 'unocss-preset-weapp'\nimport { extractorAttributify, transformerClass } from 'unocss-preset-weapp/transformer'\nimport { defineConfig } from 'unocss'\n\nconst { transformerAttributify, presetWeappAttributify } = extractorAttributify()\n\nexport default defineConfig({\n  presets: [\n    // https://github.com/MellowCo/unocss-preset-weapp\n    presetWeapp({\n      // h5兼容\n      platform: 'uniapp',\n      isH5: process.env.UNI_PLATFORM === 'h5',\n    }),\n    presetWeappAttributify(),\n  ],\n  shortcuts: [\n    {\n      'border-base': 'border border-gray-500_10',\n      'center': 'flex justify-center items-center',\n    },\n  ],\n  transformers: [\n    transformerAttributify(),\n    transformerClass(),\n  ],\n})\n```\n\n\n\n3. App.vue\n\n\u003e 使用`uno-start`和`uno-end`,作为占位符，内容随意\n\n```html\n\u003cscript\u003e\nexport default {\n  onLaunch() {\n    console.log('App Launch')\n  },\n  onShow() {\n    console.log('App Show')\n  },\n  onHide() {\n    console.log('App Hide')\n  },\n}\n\u003c/script\u003e\n\n\u003cstyle\u003e\n.uno-start {\n  --un: 0;\n}\n/* unocss 代码生成在这 */\n.uno-end {\n  --un: 0;\n}\n\u003c/style\u003e\n```\n\n\n4. main.js\n\n```js\n// 不在需要导入 uno.css\n// import 'uno.css'\n```\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmellowco%2Funocss-webpack-uniapp2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmellowco%2Funocss-webpack-uniapp2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmellowco%2Funocss-webpack-uniapp2/lists"}