Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How do get moduleId in server side rendering? #162

Open
happylindz opened this issue Jun 18, 2019 · 6 comments
Open

How do get moduleId in server side rendering? #162

happylindz opened this issue Jun 18, 2019 · 6 comments

Comments

@happylindz
Copy link

In the rendering of the server, I want to get the moduleId and then splicing out the id attribute of multiple styles, so that when the client renders, it can determine whether to insert css by judging the existence of the id, then I have not found the corresponding in the source code. Way to get about style moduleId

@frenzzy
Copy link
Member

frenzzy commented Jun 19, 2019

import style from './example.css'
const styles = style._getContent()
const [moduleId, css, media, sourceMap] = styles[0]
console.log(moduleId)

@happylindz
Copy link
Author

Thanks, another question is that could mini-css-extract-plugin extract css from js file when I use isomorphic-style-loader?

@happylindz
Copy link
Author

I found that both inline css and js file contain the same styles(Critical CSS), is that a way to remove critical css from js file.

@frenzzy
Copy link
Member

frenzzy commented Jun 20, 2019

With isomorphic-style-loader the idea was to always include css into js files but render into dom only critical css and also make this solution universal (works the same on client and server side).

If you want to extract css into separate files you probably need to find another way how to generate critical css rather than use isomorphic-style-loader.

@happylindz
Copy link
Author

Ok, i got your point. Thank you so much!

@Bigerfe
Copy link

Bigerfe commented Dec 24, 2019

const [moduleId, css, media, sourceMap] = styles[0]
This ID is different from that generated by the client, so duplicate styles will be inserted

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

No branches or pull requests

3 participants