If you have multiple applications in an NX Workspace and you are using TaiwindCSS you might have slow builds or build will be stuck when purge is enabled.
Since Angular 11.2, Tailwindcss now work out of the box. but purging is still not smooth at-list for me, maybe this might be NX Workspace problem. It took me hours to fix this.
module.exports = {
purge: {
enabled: process.env.NODE_ENV === 'production',
content: [
`./apps/**/*.html`,
'./libs/**/*.html',
],
},
mode: 'aot',
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {},
plugins: [],
},
};
Here is a possible fix.
Now to purge you need to enable it and tell tailwind where to purge.
The magic is those two environment variables
NODE_ENV
andAPP_NAME
.APP_NAME
is to make sure your build only purge the project you currently building andNODE_ENV
will enable purge.And now to finish everything, you need to add those variables in your
package.json
build script. In my workspace I have an Admin app and Store app.That's how I managed to purge Tailwind in my project, I am not sure if this is the correct way, but It's working and builds are very fast.