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

Duplicated critical css #1631

Closed
caxapexac opened this issue Dec 17, 2021 · 2 comments
Closed

Duplicated critical css #1631

caxapexac opened this issue Dec 17, 2021 · 2 comments

Comments

@caxapexac
Copy link

What is the current behaviour?
Inlined critical styles:
image
Also exists in this bundle:
image
image
Which is includes into build
How to control

Steps to Reproduce
Just preact build

What is the expected behaviour?
Part of css is critical so I can choose what to inline and what to place into bundle.css

Btw how to control which css files are inlined at all? No info in readme

@rschristian
Copy link
Member

This is intentional and correct. bundle.css needs to have the full styles, but inlining critical styles ensures fast first paint. The benefits of this should outweigh the cost of a few duplicated styles.

Critters is used to generate critical CSS.

Btw how to control which css files are inlined at all? No info in readme

CSS files aren't inlined, critical styles are. I don't know what you're looking to control. Input stylesheets? You can't, AFAIK. You could reduce the built stylesheets that Critters can use to generate critical styles, but I don't know why you would. Below is how you could alter it.

preact.config.js

export default (config, env, helpers) => {
  const critters = helpers.getPluginsByName(config, 'Critters')[0];
  if (critters) {
    critters.plugin.option.additionalStylesheets = [ '*.css' ];
  }
}

@caxapexac
Copy link
Author

Oh I just understood critters finds critical css automatically, so duplicating makes sense

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