Closed
Description
Describe the bug
A typical Next.js app built into an Nx monorepo will be located in a subfolder like ./apps/my-site
.
When the next.config.js
file is not in the project root folder, theonBuild
command fails with
Error: No static assets found in .next dist (aka no /.next/static). Please check your project configuration. Your next.config.js must be one of `serverless` or `experimental-serverless-trace`. Your build command should include `next build`.
Using base
in netlify.toml
[build] section does not fix the problem (but it is not the proper approach according the documentation as it is supposed to target a folder containing package.json
, while an Nx project contains its package.json
in its root, not in each app folder).
To Reproduce
Steps to reproduce the behavior:
- Create a monorepo project with Nx
- Add a Next.js site
- Publish it on Netlify
Expected behavior
The deployment should work
Versions
- Next.js: ^10.0.8
- plugin (if installed at fixed version): ^3.0.0
If you're using the CLI to build
- OS: [e.g. macOS, Windows]
- netlify/cli version:
If you're using file-based installation
- netlify.toml:
[build]
command = "npm run build"
publish = "dist/apps/basic"
[[plugins]]
package = "@netlify/plugin-nextjs"