Next.js: Stylesheet not included in `next export` build

Created on 6 Feb 2018  路  5Comments  路  Source: vercel/next.js

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.

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior


The stylesheet should be included in the exported build.

Current Behavior


The stylesheet is not included in the exported build.

Steps to Reproduce (for bugs)


  1. Add @zeit/next-css to your next.config.js
  2. Import a .css file
  3. Run next build
  4. Run next export
  5. Run serve ./out
  6. Run curl http://localhost:3000/_next/static/style.css to see the 404

Context


This has prevented me from migrating to Next v5.

Your Environment


| Tech | Version |
|---------|---------|
| next | 5 |
| node | 8 |
| OS | High Sierra |
| browser | * |
| etc | |

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.

All 5 comments

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",

Was this page helpful?
0 / 5 - 0 ratings

Related issues

formula349 picture formula349  路  3Comments

havefive picture havefive  路  3Comments

YarivGilad picture YarivGilad  路  3Comments

swrdfish picture swrdfish  路  3Comments

DvirSh picture DvirSh  路  3Comments