next.js recipe disjoint customServer provisions between build & serve
See original GitHub issueCurrent Behavior
serve
supports acustomServer
, butbuild
is missing such provisions. that is, though i have a custom server, the build distribution ignores it, meaning my built artifact is not runnable after build, but is runnable in dev using serve.
similarly, next.config.js
& public
assets are missing in dist, which are common next.js required artifacts
this is related, but independent of #3190
Expected Behavior
- customServer and associated provisions make it into dist. this could feasibly be a webpack::target::node execution on
customServer
placed intodist/apps/<appname>/server.js
as an optimized bundle.
Steps to Reproduce
- observe nx src for next.js serve vs build builder impls
Failure Logs
n/a
Environment
n/a
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Advanced Features: Custom Server - Next.js
If your project uses a custom server, this behavior may result in the same content being served from multiple paths, which can present...
Read more >Getting Started | Next.js
Get started with Next.js in the official documentation, and learn more about all our features!
Read more >next/server - Next.js
The NextRequest object is an extension of the native Request interface, with the following added methods and properties: cookies - A RequestCookies instance ......
Read more >Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved image ...
Read more >Going to Production - Next.js
For best results, use a production build of Next.js and use incognito in your ... to immutable assets served from /_next/static including JavaScript,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for the lack of updates. We need to rethink the custom server implementation.
As pointed out, it is only running the dev server through the custom server. We may need a migration to move it from
@nrwl/next:server
to@nrwl/next:build
since it is a build concern.We’ll have something soon, so stay tuned.
@kirjai I don’t think #5765 fixes this issue for build.
The custom server never ends up compiled into the
dist
directory.Also if you look at the dist’s package.json of each app,
start
is still"start": "next start"
not"start": "node customServer.js"
We’re run into this problem too, ended up adding a separate target to each of our nextjs apps that does @nrwl/node:build, then use @nrwl/workspace:run-commands to combine those two together.