-
Notifications
You must be signed in to change notification settings - Fork 4.3k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config - safelist in purgecss is ignored #2829
Comments
Have you tried to use I think PurgeCSS changed this API option in v3. I see in your example that you're using Tailwind 1.9, which is not using PurgeCSS 3, only Tailwind 2.x does. |
Yes, that's it! I unfortunately need to support IE11, so I should have been following these docs: https://v1.tailwindcss.com/docs/controlling-file-size#purge-css-options I'm trying to think whether there's a case for whitelisting "hidden" as a default setting given how common its usage is, but I think the view will be that it's probably up to libraries to make it clear they use 'hidden' or any other class, so will close this. |
I'm using tailwindcss 2.1.1, and module.exports = {
purge: {
content: ['./src/**/*.js'],
whitelist: [
'bg-gray-50',
'bg-red-50',
'bg-yellow-50',
'bg-green-50',
'bg-blue-50',
'bg-indigo-50',
'bg-purple-50',
'bg-pink-50',
],
},
...
}; Any idea? |
@sk8Guerra use |
@sebsobseb I've used const talwindPluginForm = require('@tailwindcss/forms');
module.exports = {
purge: {
content: ['./src/**/*.js'],
safelist: [
'bg-gray-50',
'bg-red-50',
'bg-yellow-50',
'bg-green-50',
'bg-blue-50',
'bg-indigo-50',
'bg-purple-50',
'bg-pink-50',
],
},
...
}; |
@sk8Guerra i was able to make it work by putting
|
@isaacjoh I've got it working with your solution. This is weird because the tailwind docs specifies as follows: From https://tailwindcss.com/docs/optimizing-for-production#safelisting-specific-classes
|
with using JIT mode, none of these examples solved my problem. data.js export const data = {
"class": "bg-red-0",
...
} component.jsx import { data } from "../datas/data.js";
...
<div className={`${data.class}`}> ... </div> |
@aasmpro when using JIT mode, make sure the path to your
|
@sebsobseb ty for ur answer! yeah that works and i had found it a little late! somehow that didn't work on my first try, but now everything works perfectly ;) |
@isaacjoh 's solution is the only way I was able to make it work. |
I have: |
Try it with the options param as others have stated has worked for them,
including myself
…On Tue, Sep 14, 2021, 9:32 AM gurumark ***@***.***> wrote:
I have:
"purgecss": "^4.0.3",
"tailwindcss": "^2.2.15",
It does not work for me:
module.exports = {
purge: {
content: ["layouts/**/*.html"],
safelist: [
'ais-SearchBox-input',
'ais-SearchBox-submit',
'ais-SearchBox-loadingIndicator',
'ais-SearchBox-resetIcon',
'ais-SearchBox-submitIcon',
'ais-Hits.ais-Hits--empty',
],
},
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [
require("tailwindcss-base-buttons")(),
***@***.***/typography"),
],
};
I've every solution. It simply ignores the safelist.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2829 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD2AS4NIMFGVNXL6Z6XBVJDUB52IDANCNFSM4T4AEJCQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I tried it with the options parameter too. None of the solutions on this page worked for me. I ended up hardcoding CSS comments. But it is a bug. |
In case anyone ends up here, this is what works with tailwind>2.0 and purgecss > 3.x:
and here is the link to purge css: |
Late to the party, but I thought I'd mention that in JIT, you can move the The This will change again in the upcoming Tailwind CSS 3.0 release, but for now, if you want your safelist to be respected in Tailwind v>2.2, you can move the safelist from |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the problem:
The class
hidden
was purged from my production build and I didn't spot that at first. Of course this happened because the wordhidden
doesn't appear anywhere in my files. That is because I use a library which applies the classhidden
when hiding elements, and didn't think to include that library in the list files I tell purgeCSS to check in my tailwind.config.js.I imagine I am not the only person in that situation, and thought of raising a ticket suggesting an exception for that class.
But then I tried adding
hidden
to thesafelist
, and found that doesn't seem to do anything:Link to a minimal reproduction:
Repo here: https://github.com/andyhasit/tailwindcss_bug
package.json
andcheck.sh
to make sure I'm not evil.npm i
npm run build
to produce out.css../check.sh text-red-100
which will show youtext-red-100
is in out.css (because it is in the file my-code, see config)./check.sh text-red-200
which will show youtext-red-200
is not in out.css but should be because it is insafelist
Perhaps I am doing something silly?
The text was updated successfully, but these errors were encountered: