tailwindcss-patch
get tailwindcss context at runtime!
Setup
- Install package
<yarn|npm|pnpm> add -D ts-patch
- Patch tailwindcss
npx tw-patch
- Add
prepare
script (keeps patch persisted after npm install)
package.json
{
"scripts": {
"prepare": "tw-patch"
}
}
Usage
import { getContexts, getClassCacheSet } from 'tailwindcss-patch'
getContexts()
getClassCacheSet()
Notice
getContexts
,getClassCacheSet
should be invoked after postcss-loader
's activation.
which means you may not get tailwindcss contexts at build start time.
you may call them at generateBundle
lifetime hook in vite/webpack plugin
.