-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Need update in example code about external stylesheet #2413
Comments
@giuseppeg this won't work right? Since it's not a JS export |
In my case, using
|
@timneutkens correct, styled-jsx transpiles only exported js strings/template literals. @eliot-akira in your case the error could be due to the fact that you don't import the |
@giuseppeg thanks for the confirmation 👌 |
@giuseppeg @timneutkens Sorry to bother you, but it does work in SSR. With this commit mocheng@7ac857a , the server-side-rendered HTML has I understand that @giuseppeg 's point is that webpack config only affects browser side bundling. But, this change proves that it work in SSR by injecting style into inline style. |
It seems that in the example webpack is doing the magic, but if it would be very cool if that works for ssr too. Have you also tried without the |
@giuseppeg without With |
This is really cool 😲 |
I will give it a try, if this works it is amazing because it means that people can write regular CSS in separate .css files and benefit from tooling etc. |
Alright @mocheng it works indeed! Apparently a combo of Since there is a solution though we might explore ways to allow this in a performant way – maybe we should write external compiled files for SSR in actual |
@giuseppeg I once tried to utilize |
I think that we could do that in styled-jsx I'll think about it and write a proposal. The api could be |
for regular global styles files I would just serve them from |
So is it normal behaviour with bundling?
|
@ilionic it'll be inlined in the page when you do server side rendering and in your bundle in case you load that page on the client (via router/ajax) |
see also the conversation above #2413 (comment) |
Ok I see, it's about finding compromise between performance, page size and dev experience. Critical css above-the fold is inlined ( using |
In example code about external stylesheet https://github.com/zeit/next.js/tree/master/examples/with-global-stylesheet , it still has
dangerouslySetInnerHTML
. According to thisstyled-jsx
improvement` vercel/styled-jsx#148, we can reference imported stylesheet now.I tried to change code and it works.
The
dangerouslySetInnerHTML
does not look right and might trigger eslint error. If my understanding is right, I'll submit a PR for this.The text was updated successfully, but these errors were encountered: