load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@aspect_rules_js//js:defs.bzl", "js_run_binary", "js_run_devserver")
load("@internal_npm//:next/package_json.bzl", next_bin = "bin")
# See the following pages for examples, issues, and documentation:
#
# - https://github.com/aspect-build/bazel-examples/blob/main/next.js/apps/alpha/BUILD.bazel
# - https://github.com/aspect-build/bazel-examples/blob/main/next.js/bazel/next.bzl
# - https://github.com/aspect-build/bazel-examples/issues/226
next_bin.next_binary(
name = "next_js_binary",
visibility = ["//visibility:public"],
)
ts_config(
name = "tsconfig",
src = "tsconfig.build.json",
visibility = ["//applications/crossrefs-website:__subpackages__"],
)
ts_config(
name = "tsconfig-runtime",
src = "tsconfig.json",
visibility = ["//applications/crossrefs-website:__subpackages__"],
)
srcs = [
# ...
]
data = [
":next.config.js",
":next-env.d.ts",
":tsconfig-runtime",
"//:node_modules",
]
# `next build` creates an optimized bundle of the application
# https://nextjs.org/docs/api-reference/cli#build
js_run_binary(
name = "build",
srcs = srcs + data,
args = ["build"],
chdir = package_name(),
out_dirs = [".next"],
tool = ":next_js_binary",
)
# `next dev` runs the application in development mode
# https://nextjs.org/docs/api-reference/cli#development
js_run_devserver(
name = "dev",
args = ["dev"],
chdir = package_name(),
command = "../../node_modules/.bin/next",
data = srcs + data,
)
# `next start` runs the application in production mode
# https://nextjs.org/docs/api-reference/cli#production
js_run_devserver(
name = "start",
args = ["start"],
chdir = package_name(),
command = "../../node_modules/.bin/next",
data = data + [":build"],
)
"compilerOptions": {
"noEmit": false,
"paths": {
// paths...
},
// compilerOptions...
},
// exclude, include, ...
}
"compilerOptions": {
"noEmit": true,
"paths": {
// paths...
},
// compilerOptions...
},
// exclude, include, ...
}
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
ts_project(
name = "pages",
tsconfig = "//:tsconfig",
# options, data, srcs, deps, ...
)