Skip to content

Latest commit

 

History

History

tailwindcss-patch

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

tailwindcss-patch

get tailwindcss context at runtime!

Setup

  1. Install package
<yarn|npm|pnpm> add -D ts-patch
  1. Patch tailwindcss
npx tw-patch
  1. Add prepare script (keeps patch persisted after npm install)

package.json

{
  /* ... */
  "scripts": {
    "prepare": "tw-patch"
  }
}

Usage

import { getContexts, getClassCacheSet } from 'tailwindcss-patch'
// get all contexts at runtime
getContexts()
// get all class generated by tailwindcss utilities
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.