2.0.1 purge problem(?) #2793
-
Hi all, I am trying to export tailwind css with purge. In final css file, there isn't any tailwind.config.js
package.json
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 5 replies
-
Any idea? |
Beta Was this translation helpful? Give feedback.
-
I am having the same problem. It purges all classes used in dark mode. |
Beta Was this translation helpful? Give feedback.
-
I got it working from this post: #1675 (comment) The problem most likely is that you have to set NODE_ENV=production variable in your package.json npm scripts so that it will look something like this: "scripts": { |
Beta Was this translation helpful? Give feedback.
-
@sezeregrek @shivamsn97 is this still an issue for you two? Any repo where you can reproduce the issue for us to have a look? |
Beta Was this translation helpful? Give feedback.
-
Hey! I just had a look at @shivamsn97's repo. When you are using the .dark .dark\:text-gray-200 PurgeCSS is looking for the actual You can verify that by adding Another approach is to ass purge: {
enabled: true,
preserveHtmlElements: false,
content: ["**/*.html", "**/*.js"],
+ options: {
+ safelist: ["dark"],
+ },
}, We should probably update the documentation to cover this "gotcha" 👍 |
Beta Was this translation helpful? Give feedback.
-
Thanks. I got this. |
Beta Was this translation helpful? Give feedback.
Hey!
I just had a look at @shivamsn97's repo.
When you are using the
darkMode: 'class'
strategy, the generated CSS for the dark mode variants will be:PurgeCSS is looking for the actual
dark
class name in order to keep these classes in the CSS output. If it doesn't (even if it findsdark:text-gray-200
), it will throw them away.You can verify that by adding
class="dark"
to the<body>
tag in your HTML page, and run the build command again. Dark mode classes will now be preserved.Another approach is to ass
dark
in your safelist for the purge options: