sindresorhus/strip-css-comments

Add `whitespace` option #14

andrey-semenoff posted onGitHub

Hallo! Your plugin works good, but there is one annoying fact - after removing comment block it left empty line, and it looks not very tidily. I propose to add some options to plugin to have a choice (like in gulp-strip-comments):

  • options.space ⇒ Boolean false (default) - remove comment blocks entirely true - replace comment blocks with white spaces where needed, in order to preserve the original line + column position of every code element. NOTE: When this option is enabled, option trim is ignored.
  • options.trim ⇒ Boolean false (default) - do not trim comments true - remove empty lines that follow removed full-line comments NOTE: This option has no effect when option space is enabled.

or at least add only first one.

Thanks.


Yes, that sounds like a bug.

Why would you need to preserve the line/column in CSS? It makes sense in JS where you want stack traces to point to the correct source location, but you don't have that with CSS.

posted by sindresorhus about 9 years ago

I don't need to preserve lines - it'll be enough if it just don't left empty lines in CSS. Here is CSS when plugin is off: strip-css-comments - off

And here plugin is on: strip-css-comments - on

posted by andrey-semenoff about 9 years ago

Alright. I added a failing test for this, but I don't have time to fix this right now, so PR welcome :)

posted by sindresorhus about 9 years ago

Thank you. I'll try if I could :))

posted by andrey-semenoff about 9 years ago

"Why would you need to preserve the line/column in CSS? It makes sense in JS where you want stack traces to point to the correct source location, but you don't have that with CSS."

The developer tools in chrome use the sourcemap for pointing to file and line-number. This gets all wrong if comment-stripping remove lines. I tend to do css-editing in the browser devtools, and paste the result into the correct file, so this is actually a feature I would want.

posted by lebbe about 9 years ago

I think it would make sense to implement a whitespace option, like https://github.com/sindresorhus/strip-json-comments#whitespace

posted by sindresorhus over 8 years ago

For anyone that wants to work on this, see https://github.com/sindresorhus/strip-css-comments/pull/18 for an initial attempt.


Note: This issue has a bounty, so it's expected that you are an experienced programmer and that you give it your best effort if you intend to tackle this. Don't forget, if applicable, to add tests, docs (double-check for typos), and update TypeScript definitions. And don't be sloppy. Review your own diff multiple times and try to find ways to improve and simplify your code. Instead of asking too many questions, present solutions. The point of an issue bounty is to reduce my workload, not give me more. Include a 🦄 in your PR description to indicate that you've read this. Thanks for helping out 🙌 - @sindresorhus

posted by sindresorhus about 6 years ago

@issuehunt has funded $80.00 to this issue.


posted by issuehunt-app[bot] about 6 years ago

@sindresorhus has rewarded $72.00 to @yaodingyd. See it on IssueHunt

  • :moneybag: Total deposit: $80.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $8.00
posted by issuehunt-app[bot] over 5 years ago

Fund this Issue

$80.00
Rewarded

Rewarded pull request

Recent activities

yaodingyd was rewarded by sindresorhus for sindresorhus/strip-css-comments# 14
over 5 years ago