<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sivuyile Magutywa</title>
    <description>The latest articles on DEV Community by Sivuyile Magutywa (@applicafroguy).</description>
    <link>https://dev.to/applicafroguy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F118706%2F78644737-e3bf-499e-80b5-264724709963.jpeg</url>
      <title>DEV Community: Sivuyile Magutywa</title>
      <link>https://dev.to/applicafroguy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/applicafroguy"/>
    <language>en</language>
    <item>
      <title>Angular 11.2^ + Tailwind + NX - Build slow and freezing when purge enabled</title>
      <dc:creator>Sivuyile Magutywa</dc:creator>
      <pubDate>Tue, 13 Apr 2021 11:22:56 +0000</pubDate>
      <link>https://dev.to/applicafroguy/angular-11-2-tailwind-nx-build-slow-and-freezing-when-purge-enabled-1oam</link>
      <guid>https://dev.to/applicafroguy/angular-11-2-tailwind-nx-build-slow-and-freezing-when-purge-enabled-1oam</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Here is a possible fix.&lt;/p&gt;

&lt;p&gt;I will start with &lt;code&gt;tailwind.config.js&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// tailwind.config.js
module.exports = {
  purge: [],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {},
  plugins: [],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now to purge you need to enable it and tell tailwind where to purge. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  purge: {
    enabled: process.env.NODE_ENV === 'production',
    content: [
      `./apps/${process.env.APP_NAME}/src/**/*.html`,
      './libs/**/*.html',
    ],
  },
  mode: 'aot',
  darkMode: false, // or 'media' or 'class'
  theme: {
        extend: {},
      },
      variants: {},
      plugins: [],
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The magic is those two environment variables &lt;code&gt;NODE_ENV&lt;/code&gt; and &lt;code&gt;APP_NAME&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;APP_NAME&lt;/code&gt; is to make sure your build only purge the project you currently building and &lt;code&gt;NODE_ENV&lt;/code&gt; will enable purge.&lt;/p&gt;

&lt;p&gt;And now to finish everything, you need to add those variables in your &lt;code&gt;package.json&lt;/code&gt; build script. In my workspace I have an Admin app and Store app.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// package.json
{
  "name": "myawesome-app",
  "version": "0.2.25",
  "license": "MIT",
  "main": "dist/apps/functions/main.js",
  "scripts": {
    "ng": "nx",
    "nx": "nx",
    "start": "ng serve --project store",
    "start:admin": "ng serve --project admin",
    "build:store": "NODE_ENV=production APP_NAME=store ng build --prod --project store",
    "build:admin": "NODE_ENV=production APP_NAME=admin ng build --prod --project admin",
  }
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;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.  &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
