Tailwind and cssnano
Unanswered
Masai Lion posted this in #help-forum
Masai LionOP
Hello! I have an NextJS app that uses Tailwind. I tried to add
Am I missing something?
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.
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)
@Masai Lion 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 think nextjs has already used it to minify in the production build
https://github.com/vercel/next.js/blob/c9372837dd3e261cc9902cc6626a2c95715b3db6/packages/next/package.json#L224
https://github.com/vercel/next.js/blob/c9372837dd3e261cc9902cc6626a2c95715b3db6/packages/next/src/build/webpack/plugins/css-minimizer-plugin.ts#L47C35-L47C35
https://github.com/vercel/next.js/blob/c9372837dd3e261cc9902cc6626a2c95715b3db6/packages/next/package.json#L224
https://github.com/vercel/next.js/blob/c9372837dd3e261cc9902cc6626a2c95715b3db6/packages/next/src/build/webpack/plugins/css-minimizer-plugin.ts#L47C35-L47C35