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

Control style tag position #48

Closed
bkniffler opened this issue Sep 15, 2017 · 5 comments
Closed

Control style tag position #48

bkniffler opened this issue Sep 15, 2017 · 5 comments

Comments

@bkniffler
Copy link

Hey, is there any way to control at what position the css should be put in the ? The order plays an important role and I need it to be top and not bottom-most.

@faceyspacey
Copy link
Owner

Not currently. But just grab the stylesheets instead and you can re-arrange the order.

@bkniffler
Copy link
Author

bkniffler commented Sep 16, 2017

What do you mean? The stylesheets from flushChunks? I'm doing this in my server (extract from the template, styles is the styles array from flushChunks, cssMarkup is the anchor for a css-in-js solution that I'm using)

    ${styles.map(style => `<link rel="stylesheet" type="text/css" href="${style}">`)}
    <style id="css-markup">${cssMarkup || ''}</style>

But in my client (browser), the order changes and the universal styles will be below the css-markup styles and I have no clue how to change that.

@faceyspacey
Copy link
Owner

HMR will put them in different orders during development and code splitting will likely put them at the bottom or end. Check the importCss.js file in the babel plugin to see where it a injected. Then do a PR to configure the order as an option in your babel plugin. U shouldn't need to know much babel plugin code to pass that option along to the basic js that does the importing of CSS.

@bkniffler
Copy link
Author

bkniffler commented Sep 16, 2017

Thanks, I'll play around with this. I copied the whole babel plugin into my app and I can now control the link anchor point on my own. Still thinking about the best solution, but maybe I'll try to just append it below the last <link /> tag in the head.

As a side effect of copying the universal babel plugin, my problems with faceyspacey/webpack-flush-chunks#20 went away and server rendering works fine, no more getting stuck at loading.

Thanks for your wonderful work, this is indeed the best solution for code splitting and lazy style/script loading to date!

@faceyspacey
Copy link
Owner

Thanks brother. Glad it worked out for u.

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