An unplugin-based build tool that converts UnoCSS's attributify mode attributes (e.g., bg="blue-400") into class attributes at build time, enabling attributify mode in environments like WeChat mini-programs that do not support attribute selectors. Current stable version is 0.2.5, with a 2024 release cadence. Key differentiators: supports multiple bundlers (Vite, Rollup, Webpack) via the unplugin interface; provides defaults for common attributify attributes like bg, flex, text; allows custom prefix, escape handling, and include/exclude patterns. Renamed from unplugin-unocss-attributify-wechat to better reflect its broader scope beyond WeChat.
npm install unplugin-attributify-to-classVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup for Vite with TypeScript and how attributify attributes get converted to class strings.
Update npm dependency to 'unplugin-attributify-to-class' and update import paths accordingly.
Set `attributes` option to include all attributes you want to convert, or use `prefixedOnly: false` to convert any non-standard attribute (not recommended).
Set `nonValuedAttribute: false` in options if you want to exclude non-valued attributes like `mt-2`.
Use `require('unplugin-attributify-to-class/webpack')` for Webpack projects.Use import { attributifyToClass } from 'unplugin-attributify-to-class/vite' for Vite, or the appropriate subpath for other bundlers.Use import syntax if possible, or use require from a bundler subpath (e.g., require('unplugin-attributify-to-class/webpack')).Ignore the error or extend type definitions. No runtime issue.