Replies: 4 comments 3 replies
-
Hey! We purge out of the box but don't minify, because lots of people are using other PostCSS plugins after Tailwind like autoprefixer. Best to minify as the very last step 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
Ah I understand better what you are looking for now! I think this would make sense as part of the Tailwind CLI for sure, we can add it just like autoprefixer is already included. |
Beta Was this translation helpful? Give feedback.
-
That would be amazing, and a huge win if you ask me - it would be so much simpler to use, and people would see significant reduction of their final css file size (mine went from 12KB to 4KB after minification). Thanks a lot for all the good work you guys are doing! Congrats on the launch of 2.0 and the absolute boss of a website! |
Beta Was this translation helpful? Give feedback.
-
In case anyone else has stumbled on this, here is what I did:
I then created a module.exports = ({ env }) => ({
plugins: {
tailwindcss: {},
autoprefixer: {},
cssnano: env === "production" ? { preset: "default" } : false
}
}); Then in my build scripts (in "scripts": {
"build:tailwind-dev": "tailwindcss build wwwroot/css/tailwind.css -o wwwroot/css/tailwind.generated.css",
"build:tailwind-prod": "cross-env NODE_ENV=production tailwindcss build wwwroot/css/tailwind.css -o wwwroot/css/tailwind.generated.min.css",
...
}, with: "scripts": {
"build:tailwind-dev": "postcss wwwroot/css/tailwind.css -o wwwroot/css/tailwind.generated.css",
"build:tailwind-prod": "cross-env NODE_ENV=production postcss wwwroot/css/tailwind.css -o wwwroot/css/tailwind.generated.min.css",
...
}, It's now all purged and minified and my output is tiny. I hope this helps someone :)! I'm not sure if this is the "idiomatic" way to do it - @adamwathan perhaps you can confirm? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I just upgraded to Tailwindcss 2.0. I used to have my own PostCSS config and build using postcss directly. Now I see in the documentation for 2.0 that minification (along with purging) is supported out of the box (I'm referring specifically to the
build for production part - ".. This will make sure Tailwind removes any unused CSS and minifies the CSS file for best performance..."). However when I build the css is correctly purged, but not minified.
This is how my config looks like:
Am I doing something wrong? Should I add something to enable minification?
Beta Was this translation helpful? Give feedback.
All reactions