Skip to content

Imports should be hoisted to the top #157

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

Open
nsaunders opened this issue Mar 26, 2022 · 0 comments
Open

Imports should be hoisted to the top #157

nsaunders opened this issue Mar 26, 2022 · 0 comments

Comments

@nsaunders
Copy link
Member

nsaunders commented Mar 26, 2022

Currently imports are not hoisted to the top of the CSS file. Instead, they are sorted down or remain nested (e.g. within media queries).

However, according to MDN, imported rules must precede all other types of rules, except @charset rules; as [@import] is not a nested statement it cannot be used inside conditional-group at-rules.

I propose that we follow the example of sass (see below) and hoist imports to the top. Perhaps in the future we could also accumulate queries in the process since they can be applied to @import statements directly.

Examples

purescript-css

in

query screen (singleton $ maxWidth nil) $
  star & byClass "foo" ? do
    importUrl "https://bomb.com/foo.css"
    color black

out

@media screen and (max-width: 0) { .foo { color: hsl(0.0, 0.0%, 0.0%) }
@import url(https://bomb.com/foo.css);
 }

sass

in

@media screen and (max-width: 0px) {
  .foo {
      @import "https://bomb.com/foo.css";
      color: black;
  }
}

out

@import "https://bomb.com/foo.css";
@media screen and (max-width: 0px) {
  .foo {
    color: black;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant