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

[Bug] : The default preset breaks border related styles by cssDeclarationSorter #1054

Closed
naruaway opened this issue Apr 22, 2021 · 6 comments

Comments

@naruaway
Copy link

Describe the bug
The latest version of cssnano (5.0.1) 's default preset breaks border related styles by cssDeclarationSorter.

To Reproduce
Please take a look at the minimum reproducible example.

Expected behavior

.border-top-test {
  border-color: purple;
  border-top-width: 1px;
  border-top-style: solid;
}

should not be broken by cssnano's default preset.
Currently the output is

.border-top-test {
  border-color: purple;
  border-top: 1px solid;
}

and the top border color is no longer purple.

Additional info

  • CSSNANO Version: 5.0.1
  • Plugins/presets versions: cssnano-preset-default@5.0.0
  • It is reproducible in several environments including Linux and macOS
@alan-agius4
Copy link

We can also see this issue in other cases

angular/angular-cli#20693
ionic-team/ionic-framework#23266

@ludofischer
Copy link
Collaborator

ludofischer commented May 5, 2021

Could be a bug in css-declaration-sorter since cssnano uses the keepOverrides option that should prevent these problems:


Maybe we have to fix it in https://github.com/Siilwyn/css-declaration-sorter. The problem is that css-declaration-sorter has also dropped Node.js 10 compatibility. So it would be more difficult to update to a new release.

@alexander-akait
Copy link
Member

@ludofischer maybe we should just change order of plugins

ludofischer added a commit that referenced this issue May 5, 2021
Could not detect any size reduction with css-declaration-sorter on,
it introduces bugs in certain conditions and it is hard to upgrade
without breaking Node.js 10 compatibility.

Fix #1054
@ludofischer
Copy link
Collaborator

@ludofischer maybe we should just change order of plugins

Is there a reason besides improving gzip compression that cssnano uses css-declaration-sorter? Because in my tests so far it makes compression worse, so we could remove it.

@alexander-akait
Copy link
Member

hm, I think we need test it, it always seemed to me that sorting reduces the gzip size

ludofischer added a commit that referenced this issue May 5, 2021
Could not detect any size reduction with css-declaration-sorter on,
it introduces bugs in certain conditions and it is hard to upgrade
without breaking Node.js 10 compatibility.

Fix #1054
@ludofischer
Copy link
Collaborator

#1071 fixes this (the CSS in this issue has been added to the test cases)

@ludofischer ludofischer moved this from To do to Done in merge-longhand bugs Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

4 participants