tailwindlabs / discuss

A place to ask questions, get help, or share what you've built with Tailwind CSS.
MIT License
171 stars 9 forks source link

is there any way to obfuscate the classes in the production build? #456

Open vesper8 opened 4 years ago

vesper8 commented 4 years ago

since one of the side-effects of using tailwind is that styles are usually much easier to rip/steal, especially so if @apply is not used and every class is truly inline, I thought this would have prompted someone to create some kind of obfuscator which replaces all the vanilla tailwind classes by short unintelligible hashes, with matching classes in the bundle of course so it all still works

of course, this could be reversed with a fair amount of effort, but I could still see this as being quite useful at almost no performance cost.. perhaps slightly heavier bundles because of slightly more characters in the classes. Still, I would use that if it existed

This would also be useful if you are selling templates built with Tailwind CSS and want to provide a live demo

adamwathan commented 4 years ago

First tool I'd try is this one:

https://github.com/posthtml/posthtml-minify-classnames

vesper8 commented 4 years ago

thank you, I'm having a look, at first glance it seems this isn't easy to use or compatible with bundles created through Webpack though.. but it's a step in the right direction!

I think this would be pretty useful to cover to protect the templates in your upcoming Tailwind UI product

vesper8 commented 4 years ago

I just dug around a bit and found this https://github.com/sndyuk/mangle-css-class-webpack-plugin which I'm currently testing and having very good results with.. seems very promising