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

Ignore specific styles #895

Closed
strarsis opened this issue Feb 15, 2017 · 11 comments
Closed

Ignore specific styles #895

strarsis opened this issue Feb 15, 2017 · 11 comments

Comments

@strarsis
Copy link
Contributor

strarsis commented Feb 15, 2017

It would be nice to let clean-css skip specific rulesets/declarations/blocks e.g. by
surrounding them with terminated comments, e.g.:

/* #clean-css: ignore */
.ignore-me {
  color: transparent;
}
/* #clean-css: /ignore */
@jakubpawlowicz
Copy link
Collaborator

This is an interesting concept!

So given this input:

.block-1 {
  color: #f00;
}
/* #clean-css: ignore */
.ignore-me {
  color: transparent;
}
/* #clean-css: /ignore */
.block-2 {
  margin: 0px;
}

should the output (let's assume we use format: 'keep-breaks') be:

.block-1{color:red}
/* #clean-css: ignore */
.ignore-me{color:transparent}
/* #clean-css: /ignore */
.block-2{margin:0}

?

Should this mechanism:

  • keep the comments?
  • remove whitespace in preserved block?

@studio404pl
Copy link

@jakubpawlowicz - Cześć :)

+1 to that, it would be great to just keep some sections not parsed at all, content between tags should just be passed as raw css.

@jakubpawlowicz
Copy link
Collaborator

jakubpawlowicz commented Mar 20, 2017

@studio404pl hej! :-)

Do you think the output should still contain the /* #clean-css: ignore */ and /* #clean-css: /ignore */ comments? What's the "standard" syntax for such comments anyway?

@studio404pl
Copy link

studio404pl commented Mar 20, 2017

@jakubpawlowicz i think syntax that you suggested is ok. IMHO this condition's comments should not be included in parsed file.

@jakubpawlowicz
Copy link
Collaborator

Ok, thanks for input!

@strarsis
Copy link
Contributor Author

In my opinion, it would be nice to not only to set ignore option per block but also other options like the aforementioned 'format: keep-breaks, so this kind of block can not only be used for ignoring styles but also for just setting specific options.

@jakubpawlowicz
Copy link
Collaborator

@strarsis we'll start with something simple here as having a per-block options would bump the complexity greatly.

@FRSgit
Copy link

FRSgit commented Jun 7, 2017

@jakubpawlowicz Any updates on when can it be ready or how to help with bringing that functionality?
I came to the situation in which there is no other way but to use these ignore comments.

But have one proposal - let's use comment naming standard set by jshint as it's quite recognisable, link (under "ignore" title).

So example will look like this:

.block-1{color:red}
/* clean-css ignore:start */
.ignore-me{color:transparent}
/* clean-css ignore:end */
.block-2{margin:0}

And I guess we can think of introducing single-line ignore-comments as well, but initially, it's not necessary.

@jakubpawlowicz
Copy link
Collaborator

I think we can have it in 4.2 but I need to dig how complex it is first.

@strarsis @studio404pl what do you think about ^ suggestion re comment naming?

jakubpawlowicz added a commit that referenced this issue Jun 7, 2017
Why:

* Allows parts of CSS document to be wrapped between
  /* clean-css ignore:start */ and /* clean-css ignore:end */ comments
  passing them to output untouched by parsing and optimizing;
* in case of some special stylesheets when optimizations can break
  styling.
@jakubpawlowicz
Copy link
Collaborator

^ the preliminary version supporting the ignore:start / ignore:end syntax which I personally find more intuitive.

@jakubpawlowicz jakubpawlowicz modified the milestone: 4.2.0 Jun 7, 2017
jakubpawlowicz added a commit that referenced this issue Jun 16, 2017
Why:

* Allows parts of CSS document to be wrapped between
  /* clean-css ignore:start */ and /* clean-css ignore:end */ comments
  passing them to output untouched by parsing and optimizing;
* in case of some special stylesheets when optimizations can break
  styling.
jakubpawlowicz added a commit that referenced this issue Jun 16, 2017
Why:

* Allows parts of CSS document to be wrapped between
  /* clean-css ignore:start */ and /* clean-css ignore:end */ comments
  passing them to output untouched by parsing and optimizing;
* in case of some special stylesheets when optimizations can break
  styling.
@jakubpawlowicz
Copy link
Collaborator

Added in master, scheduled for 4.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants