Use tailwindcss-patch 2.x to extract your classNames
#11827
sonofmagic
started this conversation in
Show and tell
Replies: 1 comment
-
|
I want this feature very badly, to build an optimized build pipeline that can skip rebuilding Tailwind if some files changed, but not the actual list of classes in those files. But I'm not too keen on "patching" my Tailwind version as advertised here. Is there any chance we can get a feature like this (extract the list of found classes and write it somewhere, say a JSON file) in upstream Tailwind? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Use
tailwindcss-patch 2.xto extract your classNamestailwindcss-patchis an extension to thetailwindcssecosystem. It is also an important part of thetailwindcss-mangleproject.I recently released
2.xversion oftailwindcss-patch, which adds a configuration file reading and tool class name extraction feature.Let's see how to use it. It's fairly simple!
tailwindcss-patch 2.xto extract your classNamesSetup
preparescript (keeps patch persisted after npm install)package.json{ /* ... */ "scripts": { "prepare": "tw-patch install" } }Usage
Cli
Extract all class into a json
default there will be a json in
.tw-patch/tw-class-list.jsonin your project.you can custom this behavior by config
tailwindcss-mangle.config.tsNodejs API
Config
Init Config File
Then there will be a ts file called
tailwindcss-mangle.config.tsexist in yourcwd.The config as follows:
you can custom
tw-patchbehavior bypatchoption:What's next?
At the moment I just extracted all the tool classes to actually get the context of
tailwindcssto analyze. You can add more functionality to this project by giving meissueorpr.Of course, the extracted
JSONisn't just for you to look at. You can analyze it, and I use it as a data file for mytailwindcss-mangle.The
tailwindcss-mangleitself is an obfuscation tool to obfuscate the tools generated bytailwindcss, see the next article for more details on how to use it.Beta Was this translation helpful? Give feedback.
All reactions