Skip to content

How do I remove the comments and minify the generated CSS output from Tailwind? #2160

Answered by simonswiss
arentsen asked this question in Help
Discussion options

You must be logged in to vote

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:

module.exports = {
  plugins: [
    // ...
    require('tailwindcss'),
    require('autoprefixer'),
    require('cssnano'),
    // ...
  ]
}

It might be worth only running cssnano for production:

module.exports = {
  plugins: [
    require('tailwindcss'),
    require('autoprefixer'),
    ...process.env.NODE_ENV === 'production'
      ? [require('cssnano')]
      : []
  ]
}

Hope it helps! 👍

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@arentsen
Comment options

Answer selected by simonswiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants