-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Preserve author's format #2544
Comments
Why do you want this? Whether or not a leading zero is present doesn't affect the meaning of the generated CSS. Is this just an aesthetic concern? Because Sass's output formatting is not intended to be deeply customizable; it's intended to be readable and consistent. We preserve the output format of colors because there were spec-violating inconsistencies in handling different forms of colors across browsers, but tracking the original format of each color object is quite expensive. Numbers are used even more often than colors, which means the performance hit would be even more substantial. There would have to be an extremely compelling reason to track their format. |
Smaller CSS, every byte counts.
True it does not change the meaning the css code.
While I agree that all our CSS should be readable and consistent. With the change in Dart where sass now also removes quotes on attributes. |
If you're looking for small CSS, use compressed mode, where Sass will always generate the smallest CSS it can. Otherwise, Sass will generate valid CSS that's readable and consistent. It doesn't make sense to add more choices than that. |
Okay makes sense, if compressed mode did not add the leading zero. |
@nex3 Sorry again, but your last comment is incorrect, Compresses mode also adds the leading zero.
How is this the smallest CSS. |
I can't reproduce this:
|
Okay to make sure on my side I ran just sass, no other npm packages. ❯ npm list -dept=0
..
node-sass@4.9.2
sass@1.10.0
.. The compressed mode did indeed leave number values allone. But did not for rgba colors. Also wierd difference between dart and node sass for numbers passed via interpolation. I need to use interpolation for sass variables that are passed as value for css variables. /* output without interpolation */
:root{--item-spacer: $item-spacer;} |
This also works for me:
In Dart Sass, the conversion of a value to a string that occurs during interpolation has no knowledge of the output style that will eventually be generated for it. This makes it much more efficient and modular, but it does mean that sometimes you may end up with leading zeros. |
Running $(npm bin)/node-sass ..... --output-style compressed
Output:
If anyone is able to find solution/workaround, please let me know. |
Fixed it by writing a function, I believe there is config available in node-sass itself, for now I don't know it yet!
NOTE: This will break if not using --output-style compressed |
The only guarantee Sass makes about the format of non-integer numbers—including when they're converted to strings using |
@nex3, thank you for explaining the way it is implemented, it would be helpful if there is an config option available to add the leading zero based on developer interest, because even with such scss functions in above we *cannot detect if css is generated normally or in compressed mode. *If possible, let us know |
We generally don't add configuration options for language behavior. Doing so would mean that stylesheets couldn't be used across different projects with different configurations, which damages our goal of providing a platform for stylesheet libraries. Generally, you shouldn't write your styles in a way that assumes anything about how non-integer numbers will be formatted beyond what Sass guarantees. If you want a consistent format, first convert them to integers. |
I am amazed that sass (in any form, ruby, lib and dart) all have similar issues around some formatting options.
While I don't mind all forms like the one from #30 by removing the quotes from attributes (Only in Dart).
One issue that is bugging me to this day is that sass will simply add a leading-zero to my css code and there is no way to tell sass to not do this.
Sass should not decide how we write our css.
Other tools should.
Please keep the author's format when not using compressed.
Like with colors #363
At Least stop adding leading-zeros!
P.S. yes there have been previous tickets for the leading-zero issue which all have been marked as a duplicate to each other and end up to the Ruby-sass version that is closed because Ruby Sass is deprecated
This is not just related to Ruby-sass.
I am using both Dart- and Lib-sass in my project.
And both also do this.
The text was updated successfully, but these errors were encountered: