Back to Nuxt

nuxt build

docs/4.api/4.commands/build.md

4.4.42.8 KB
Original Source
<!--build-cmd-->
bash
npx nuxt build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName] [-e, --extends=<layer-name>] [--profile[=verbose]]
<!--/build-cmd-->

The build command creates a .output directory with all your application, server and dependencies ready for production.

Arguments

<!--build-args-->
ArgumentDescription
ROOTDIR="."Specifies the working directory (default: .)
<!--/build-args-->

Options

<!--build-opts-->
OptionDefaultDescription
--cwd=<directory>Specify the working directory, this takes precedence over ROOTDIR (default: .)
--logLevel=<silent|info|verbose>Specify build-time log level
--prerenderBuild Nuxt and prerender static routes
--preset=<preset>Specify Nitro server preset. Available presets depend on Nitro (e.g. node-server, vercel, netlify, static)
--dotenvPath to .env file to load, relative to the root directory
--envNameThe environment to use when resolving configuration overrides (default is production when building, and development when running the dev server)
-e, --extends=<layer-name>Extend from a Nuxt layer
--profileProfile performance (v4.4+). Writes a V8 CPU profile and JSON report on exit. Use --profile=verbose for a full console report.
<!--/build-opts-->

::note This command sets process.env.NODE_ENV to production. ::

::note --prerender will always set the preset to static ::