blob: 89a644f11e2d5a95b43384de72b9a9017ca7cb92 [file]
load("@aspect_rules_js//contrib/nextjs:defs.bzl", "nextjs_standalone_build", "nextjs_standalone_server")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//nextjs:next/package_json.bzl", next_bin = "bin")
npm_link_all_packages()
# The nextjs binary target to used by nextjs:defs.bzl
next_bin.next_binary(
name = "next_js_binary",
visibility = ["//visibility:public"],
)
js_library(
name = "lib",
srcs = glob([
"src/**",
"public/**",
]),
deps = [
":node_modules/next",
":node_modules/react",
":node_modules/react-dom",
],
)
js_library(
name = "nextjs-css",
srcs = [
"postcss.config.mjs",
],
deps = [
":node_modules/@tailwindcss/postcss",
":node_modules/tailwindcss",
],
)
# The standard nextjs build/start/dev workflow
# nextjs(
# name = "app",
# srcs = [
# "jsconfig.json",
# ":nextjs-css",
# ":lib",
# ],
# config = "next.config.mjs",
# next_js_binary = ":next_js_binary",
# )
# A standalone nextjs build
nextjs_standalone_build(
name = "standalone",
srcs = [
"jsconfig.json",
":lib",
":nextjs-css",
],
config = "next.standalone.mjs",
next_js_binary = ":next_js_binary",
silent_on_success = False,
)
# A standalone server
nextjs_standalone_server(
name = "server",
app = ":standalone",
)
# Verify next (which has optional platform/os specific dependencies) can be built
build_test(
name = "next_build_test",
targets = [":node_modules/next"],
)
write_source_files(
name = "write_next_links_defs",
files = {
"snapshots/next_links_defs.bzl": "@npm__next__15.2.6_1816342077__links//:defs.bzl",
},
tags = [
"skip-on-bazel8",
"skip-on-bazel9",
],
)