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

Ignored imports cause re-ordering of CSS #536

Closed
romainmenke opened this issue Jul 21, 2023 · 2 comments
Closed

Ignored imports cause re-ordering of CSS #536

romainmenke opened this issue Jul 21, 2023 · 2 comments

Comments

@romainmenke
Copy link
Collaborator

This has been part of this plugin since the first release :

if (parsedAtImport.path.match(/[a-z]+:\/\//i)) {

current code :

// skip protocol base uri (protocol://url) or protocol-relative
if (stmt.type !== "import" || /^(?:[a-z]+:)?\/\//i.test(stmt.uri)) {
continue
}
if (options.filter && !options.filter(stmt.uri)) {
// rejected by filter
continue
}


@import "foo.css";
@import "https://font.service/my-font.css";
@import "bar.css";

It will be re-ordered by postcss-import :

@import "https://font.service/my-font.css";
foo{}
bar{}

I think we should at least warn when this scenario happens :

  • an @imports can not be inlined
  • it follows other @imports's that were inlined
@RyanZim
Copy link
Collaborator

RyanZim commented Jul 22, 2023

Yeah, a warning would be prudent here.

@romainmenke
Copy link
Collaborator Author

I didn't find a good way to add a warning for this edge case without adding a lot of complexity.

I did however recently created a stylelint plugin with some warnings for edge cases in CSS bundlers.

I also added a warning for this edge case there : https://github.com/csstools/postcss-plugins/blob/3163647e778da39116303234e82f0049f7f07560/plugins-stylelint/no-invalid-at-import-rules-when-bundling/index.test.js#L61-L67

I suggest we close this issue as won't fix

@RyanZim RyanZim closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants