project.json:

//... { "name": "acme", "$schema": "node_modules/nx/schemas/project-schema.json", "sourceRoot": ".", "projectType": "application", "targets": { //... "build": { "executor": "@nx/next:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", "options": { "root": ".", "outputPath": "dist/acme" } } //... } }
Nx 15 and lower use @nrwl/ instead of @nx/
nx run acme:build

Examples

For Next.js Standalone projects

This is the default configuration for Next.js standalone projects. Our @nx/next:build executor is integrated to use Next.js' CLI. You can read more about the build options at Next.js CLI Options

"build": { "executor": "@nx/next:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", "options": { "root": ".", "outputPath": "dist/acme" }, "configurations": { "development": { "outputPath": "." }, "production": {} } },
Nx 15 and lower use @nrwl/ instead of @nx/

Options

outputPath

Required
string

The output path of the generated files.

nextConfig

string

Path (relative to workspace root) to a function which takes phase, config, and builder options, and returns the resulting config. This is an advanced option and should not be used with a normal Next.js config file (i.e. next.config.js).

buildLibsFromSource

boolean
Default: true

Read buildable libraries from source instead of building them separately.

debug

boolean

Enable Next.js debug build logging

experimentalAppOnly

boolean

Only build 'app' routes

fileReplacements

Default: []

Replace files with other files in the build.

includeDevDependenciesInPackageJson

boolean
Default: false

Include devDependencies in the generated package.json file. By default only production dependencies are included.

profile

boolean

Used to enable React Production Profiling

generateLockfile

boolean
Default: false

Generate a lockfile (e.g. package-lock.json) that matches the workspace lockfile to ensure package versions match.