Next.js Discord

Discord Forum

Tailwind and cssnano

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hello! I have an NextJS app that uses Tailwind. I tried to add cssnano: {} to the app's postcss.config.js file, but when I do a production build, I get CSS files with no class name minified.
Am I missing something?

4 Replies

Hi, did you follow the documentation?

https://tailwindcss.com/docs/optimizing-for-production

If yes, please share the content of the postcss.config.js file content.
Masai LionOP
Here is my postcss config:
module.exports = {
  plugins: {
    'postcss-import': {},
    tailwindcss: {
      config: join(__dirname, 'tailwind.config.js'),
    },
    autoprefixer: {},
    cssnano: {},
    // ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {}),
  },
};
(I commented the conditional version for cssnano to make sure it was taken into account)