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

@import url("a.css"); files get ignored #294

Open
mikeytown2 opened this issue Mar 28, 2018 · 3 comments
Open

@import url("a.css"); files get ignored #294

mikeytown2 opened this issue Mar 28, 2018 · 3 comments

Comments

@mikeytown2
Copy link

If you want to take this to the extreme make a webpage that uses this style for loading css

<style type="text/css" media="all">
@import url("a.css");
@import url("b.css");
@import url("c.css");
@import url("d.css");
@import url("e.css");
</style>

When running critical https://import.css.url.com/ it'll spit out this "Error: css should not be empty" even though css files do exist.

@bezoerb
Copy link
Collaborator

bezoerb commented Apr 1, 2018

Inline styles are currently not processed by critical so these imports are invisible to critical.
You could work around this by specifying the imported stylesheets in the options like this:

critical.generate({
  css: ['a.css', 'b.css', ...]
});

Even though inline-critical won't process the inline styles either so you would end up with the critical css inlined alongside the inline styles with the @import statements ;)

Why don't you use <link rel="stylesheet"> tags?

@mikeytown2
Copy link
Author

mikeytown2 commented Apr 2, 2018

import can in in the CSS as well; this syntax just makes testing it a lot easier. What file would I need to edit in order to do a pull request for this feature? Could you point me the right direction?

@bezoerb
Copy link
Collaborator

bezoerb commented Apr 3, 2018

The stylesheets are extracted with oust
You can find this in lib/core.js.
The critical css is inlined with inline-critical. So if you like you can prepare a PR on these two packages.

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