Documentation for @aspect_rules_js@v3.0.3 — View source
next_js_binary target passed into the macros.
This is normally generated once alongside the package.json containing the next dependency:
Standard Build
nextjs(): wrap the build+dev+start targetsnextjs_build(): the Next.js build commandnextjs_dev(): the Next.js dev commandnextjs_start(): the Next.js start command, accepting a Next.js build artifact to start
Standalone Mode
For standalone applications:nextjs_standalone_build(): the Next.js build command, configured for a standalone application within bazelnextjs_standalone_server(): constructs a standalone Next.js serverjs_binaryfollowing the standalone directory structure guidelines
Function: nextjs
Generates Next.js build, dev & start targets.
{name} - a Next.js production bundle
{name}.dev - a Next.js devserver
{name}.start - a Next.js prodserver
Use this macro in the BUILD file at the root of a next app where the next.config.mjs
file is located.
For example, a target such as //app:next in app/BUILD.bazel
next build outside Bazel:
next dev outside Bazel:
next start outside Bazel:
Parameters
unknown
required
the name of the build target
unknown
required
Source files to include in build & dev targets.
Typically these are source files or transpiled source files in Next.js source folders
such as
pages, public & styles.unknown
required
The next
js_binary target to use for running Next.jsTypically this is a js_binary target created using bin loaded from the package_json.bzl
file of the npm package.See main docstring above for example usage.unknown
default:"next.config.mjs"
the Next.js config file. Typically
next.config.mjs.unknown
default:"[]"
Data files to include in all targets.
These are typically npm packages required for the build & configuration files such as
package.json and next.config.js.
unknown
default:"[]"
Data files to include in devserver targets
unknown
Other attributes passed to all targets such as
tags.Function: nextjs_build
Build the Next.js production artifact.
See https://nextjs.org/docs/pages/api-reference/cli/next#build
Parameters
unknown
required
the name of the build target
unknown
required
the Next.js config file
unknown
required
the sources to include in the build, including any transitive deps
unknown
required
The next
js_binary target to use for running Next.jsTypically this is a js_binary target created using bin loaded from the package_json.bzl
file of the npm package.See main docstring above for example usage.unknown
default:"[]"
the data files to include in the build
unknown
Other attributes passed to all targets such as
tags, envFunction: nextjs_start
Run the Next.js production server for an app.
See https://nextjs.org/docs/pages/api-reference/cli/next#next-start-options
Parameters
unknown
required
the name of the build target
unknown
required
the Next.js config file
unknown
required
the pre-compiled Next.js application, typically the output of
nextjs_buildunknown
required
The next
js_binary target to use for running Next.jsTypically this is a js_binary target created using bin loaded from the package_json.bzl
file of the npm package.See main docstring above for example usage.unknown
default:"[]"
additional server data
unknown
Other attributes passed to all targets such as
tags, envFunction: nextjs_dev
Run the Next.js development server.
See https://nextjs.org/docs/pages/api-reference/cli/next#next-dev-options
Parameters
unknown
required
the name of the build target
unknown
required
the Next.js config file
unknown
required
the sources to include in the build, including any transitive deps
unknown
required
additional devserver runtime data
unknown
required
The next
js_binary target to use for running Next.jsTypically this is a js_binary target created using bin loaded from the package_json.bzl
file of the npm package.See main docstring above for example usage.unknown
Other attributes passed to all targets such as
tags, envFunction: nextjs_standalone_build
Compile a standalone Next.js application.
See https://nextjs.org/docs/app/api-reference/config/next-config-js/output#automatically-copying-traced-files
NOTE: a next.config.mjs is generated, wrapping the passed config, to overcome Next.js limitation with bazel,
rules_js and pnpm (with hoist=false, as required by rules_js).
Due to the generated next.config.mjs file the nextjs_standalone_build(config) must have a unique name
or file path that does not conflict with standard Next.js config files.
Issues worked around by the generated config include:
Parameters
unknown
required
the name of the build target
unknown
required
the Next.js config file
unknown
required
the sources to include in the build, including any transitive deps
unknown
required
the Next.js binary to use for building
unknown
default:"[]"
the data files to include in the build
unknown
Other attributes passed to all targets such as
tags, envFunction: nextjs_standalone_server
Configures the output of a standalone Next.js application to be a standalone server binary.
See the Next.js standalone server documentation
for details on the standalone server directory structure.
This function is normally used in conjunction with nextjs_standalone_build to create a standalone
Next.js application. The standalone server is a js_binary target that can be run with bazel run
or deployed in a container image etc.
Parameters
unknown
required
the name of the binary target
unknown
required
the standalone app directory, typically the output of
nextjs_standalone_buildunknown
default:"None"
the directory server.js is in within the standalone/ directory.This is normally the application path relative to the pnpm-lock.yaml.Default: native.package_name() (for a pnpm-lock.yaml in the root of the workspace)
unknown
default:"[]"
runtime data required to run the standalone server.Normally requires
[":node_modules/next", ":node_modules/react"] which are not included
in the Next.js standalone output.unknown
additional
js_binary attributes
