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

inlining css styles in the head tag via getCssLinks() and custom document does not work anymore in v8.1 #7641

Closed
badpenguin opened this issue Jun 23, 2019 · 6 comments

Comments

@badpenguin
Copy link

Describe the bug

After upgrading, and cleaning any temporary data i got a strange issue.

The build + export procedure is working and the generated web site is perfect.

However launching the dev server will start but will not work: when i try to browse to localhost:3000 i get 404 no matter which page's url i try to access.

What can i do to generate some usefull debugging for this issue?

@huv1k
Copy link
Contributor

huv1k commented Jun 23, 2019

Hey @badpenguin, from your response it's hard to debug what is wrong. Could you please provide minimal reproduction?

@badpenguin
Copy link
Author

badpenguin commented Jun 23, 2019

Ok i figured it out! but didn't solved it.
First of all i've an errore caused by fs.readFileSync() in page/_documents.tsx and this is causing a 404 instead of an error stack trace.
My problems is that i forked getCssLinks() to inline the CSS styles instead of loading them.
In production mode its working.
In development mode i found a "bug" maybe?
this.context._documentProps.files contains the list of CSS and JS resource to load.
In development mode i have the file dist/_next/static/css/styles.chunk.css
this does not exists on disk, the one on disk is styles.35775087.chunk.css

Instead when i run in production mode it works correctly since they bot
styles.35775087.chunk.css.

At the moment i've mitigated the problem changing the code to use LINK (with URL) instead of STYLE in dev mode if the file does not exists on disk.

The code i use for inlining css in the head via custom _document can be found here:
https://github.com/badpenguin/nextjs-static-generator-boilerplate/blob/master/src/lib/NextHeadWithInlineCss.tsx

@badpenguin badpenguin changed the title dev server not working after upgrading from v7 to v8.1 inlining css styles in the head tag via getCssLinks() and custom document does not work anymore in v8.1 Jun 23, 2019
@badpenguin
Copy link
Author

Source code to test this behaviour with 8.1 has been published here https://github.com/badpenguin/nextjs-static-generator-boilerplate/tree/v8.1.0

@timneutkens
Copy link
Member

Sounds like you're doing something unexpected / non-standard.

@badpenguin
Copy link
Author

badpenguin commented Aug 10, 2019

Sounds like you're doing something unexpected / non-standard.

It there a "standard" way to not generate all that pre-load scripts that slows down the initial page load, then?

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants