I've just started moving an app over to Next v5. I'm doing this in small chunks, and have just finished a page. In order to verify it in production-mode, I ran the build (NODE_ENV=production next build && NODE_ENV=production next export). The styles.css file is correctly build/saved to ./.next/static/styles.css, but it is not included in the exported build (./out/**).
This results in 404s when requesting the stylesheet.
The stylesheet should be included in the exported build.
The stylesheet is not included in the exported build.
@zeit/next-css to your next.config.jsnext buildnext exportserve ./outcurl http://localhost:3000/_next/static/style.css to see the 404
This has prevented me from migrating to Next v5.
| Tech | Version |
|---------|---------|
| next | 5 |
| node | 8 |
| OS | High Sierra |
| browser | * |
| etc | |
I ran into the same issue. Until this get's a proper fix. I added this to my package.json scripts
"export": "next build && next export && cp -R ./.next/static ./out/_next/static/"
We actually fixed this.
Check this canary version: https://github.com/zeit/next.js/releases/tag/5.0.1-canary.1
We'll ship a stable release soon.
Can confirm this is fixed in 5.0.1-canary.1!
Just tried the 5.0.1-canary.6 -- the stylesheet is now linked properly when assetPrefix is not defined in next.config.js, but fails when it is defined. Script files are included as <my prefix>/_next/<...>/index.js, while the css file is included as /_next/static/style.css with no prefix.
The same problem!!! Not included with build, but working in dev.
_document
<link rel="stylesheet" href="/_next/static/style.css" />
package
"next": "^6.0.4-canary",
Most helpful comment
We actually fixed this.
Check this canary version: https://github.com/zeit/next.js/releases/tag/5.0.1-canary.1
We'll ship a stable release soon.