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

How Critical Css with exact path="/" of the Reactjs #29

Open
crazychicken opened this issue Sep 22, 2018 · 4 comments
Open

How Critical Css with exact path="/" of the Reactjs #29

crazychicken opened this issue Sep 22, 2018 · 4 comments
Labels

Comments

@crazychicken
Copy link

I have a case use two component with

import Navbar from './shares/Navbar'
<NavBar /> // It is work

// It is not work

import Home from './views/HomeView'
<Route exact path="/" component={HomeView} />

Default config:

new HtmlCriticalWebpackPlugin({
  base: path.resolve(__dirname, 'dist'),
  src: 'index.html',
  dest: 'index.html',
  inline: true,
  minify: true,

  extract: true,
  width: 1330,
  height: 680,
  include: ['.class_home'], // it is work
  penthouse: {
    blockJSRequests: false,
  }
})

i tried use include:['.class_name', 'some_class'] of critical. But, i have many class and id. You can tell me edit that.

@thescientist13
Copy link
Collaborator

thescientist13 commented Sep 22, 2018

This might just be an issue with critical itself. This plugin just makes critical callable as part of a webpack build process, and not much to do with critical itself.

That said, I'm not familiar with include API, so maybe if you could explain a little more about what the expected outcome is that you're looking for, there might be something we could help with.

@crazychicken
Copy link
Author

This is my issue:
i have two component use critical-css,
<Navbar />, <Slider />,

work
It is work with (.slider, .slider-item) 💯 👍

But, when i want use component only the home-page,
I use:
<Route exact path="/" component={Slider} />

it is not work. :(
not-work

Can you suggest to me, how to fix it.
Thank you.

@thescientist13
Copy link
Collaborator

thescientist13 commented Sep 30, 2018

Hmm, I see.

This could be an issue with how critical process code specific to Single Page Applications, where chunks are generated async? I think it's something I've run into I think, and haven't had time to look into it further on the critical side. (maybe related to an other open issue #30 )

Maybe there are some issues in the critical issue tracker about how to best use critical with async / SPA frameworks like React?

@thescientist13
Copy link
Collaborator

Just to follow up, a user with a similar report found that running critical manually also produced the same results, so maybe critical itself isn't well suited to SPAs?

Can you please confirm as well? Might not be a plugin issue.
#39 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants