Skip to content
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

[Feature] Ignore class with a comment in it #225

Closed
n1kk opened this issue Sep 27, 2019 · 0 comments
Closed

[Feature] Ignore class with a comment in it #225

n1kk opened this issue Sep 27, 2019 · 0 comments
Projects

Comments

@n1kk
Copy link
Contributor

n1kk commented Sep 27, 2019

Hi, I had a need for this feature so I've implemented it and made a PR and completely forgot about it :) #210

Is your feature request related to a problem? Please describe.
At my current project we use PostCSS together with SCSS and the problem arises when we need to ignore lists of generated classes that will be used dynamically. There's to much to keep them in the whitelist array and existing ignore comments do not really cover our case easily.

If we use /* purgecss ignore */ before generated class then it doesn't work since the comment is left in the body of parent class:

.parent {
	/* ... */
	@for $i from 1 through $max-size {
		/* purgecss ignore */
		&.size-#{$i} {
			/* ... */
		}
	}
}

turns to

.parent {
	/* ... */

	/* purgecss ignore */
	/* purgecss ignore */
	/* purgecss ignore */
}

.parent .size-1 { /* ... */ }
.parent .size-2 { /* ... */ }
.parent .size-3 { /* ... */ }

and as you can see all the comments are left in the body of the parent class.

Describe the solution you'd like
I've added another ignore comment /* purgecss ignore current */ so that every class that has this comment inside is ignored.

.parent {
	/* ... */
	@for $i from 1 through $max-size {
		&.size-#{$i} {
			/* purgecss ignore current */
		}
	}
}

turns to

.parent {
	/* ... */
}

.parent .size-1 { /* purgecss ignore current */ }
.parent .size-2 { /* purgecss ignore current */ }
.parent .size-3 { /* purgecss ignore current */ }

Describe alternatives you've considered
There's obviously workarounds but they all either add overhead or another layer of redundant data/lists to maintain and potentially break things. The start/end comments also are left behind in parent body so they only will work if you use them at root level and that means basically ignoring the whole file in our case.

@n1kk n1kk changed the title Ignore class with a comment in it [Feature] Ignore class with a comment in it Sep 27, 2019
@Ffloriel Ffloriel added this to To do in Next Oct 7, 2019
@Ffloriel Ffloriel moved this from To do to Done in Next Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Next
  
Done
Development

No branches or pull requests

2 participants