Next.js Discord

Discord Forum

Minify tailwind classnames in Next 14

Unanswered
Tomistoma posted this in #help-forum
Open in Discord
TomistomaOP
This feels like it should be such a simple task but I've been at it for ages and tried so many libraries and yet I've found no way to do it. I would like to minify css classnames so there's less to download on the user's end. I've gone through a variety of plugins unique to postcss and of the one the ones that worked at all, they just outputted an object mapping the names and expected me to implement the classname replacing myself, which I'm not sure how to do in Next. I then tried next-css-obfuscator but that runs into some sort of syntax error in the compiled CSS which I can only assume is to do with the CSS nesting as there is an open issue for supporting that. I also tried nextjs-plugin-minify-css-classname and although there is no error, it just does nothing even when forcing it to be enabled all the time.

Does anyone know of a way to do this? Seems helpful with tailwind where there can be some fairly long names.

0 Replies