How do I remove the comments and minify the generated CSS output from Tailwind? #2160
-
My Craft project is in development stage and if I build my tailwind CSS file, it is huge because of all the comments in it. I would just like to minify it (even without using purgeCSS for all the unused classes at this point) but I cannot find any information on it. How do I do this? |
Beta Was this translation helpful? Give feedback.
Answered by
simonswiss
Aug 19, 2020
Replies: 1 comment 1 reply
-
Hi @arentsen! 👋 For this you could use cssnano, another PostCSS plugin. You can add the plugin to your your array in your module.exports = {
plugins: [
// ...
require('tailwindcss'),
require('autoprefixer'),
require('cssnano'),
// ...
]
} It might be worth only running module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
...process.env.NODE_ENV === 'production'
? [require('cssnano')]
: []
]
} Hope it helps! 👍 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
simonswiss
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @arentsen! 👋
For this you could use cssnano, another PostCSS plugin.
You can add the plugin to your your array in your
postcss.config.js
like so:It might be worth only running
cssnano
for production:Hope it helps! 👍