diff --git a/bins/build.mjs b/bins/build.mjs index 3cb2d57890a7..089aa45e8e1f 100644 --- a/bins/build.mjs +++ b/bins/build.mjs @@ -1,5 +1,16 @@ #!/usr/bin/env node import { rariBin } from "@mdn/rari"; import { spawn } from "cross-spawn"; +import { config } from "dotenv"; +import path from "node:path"; +import { cwd } from "node:process"; + +import { BUILD_OUT_ROOT } from "../libs/env/index.js"; + +config({ + path: path.join(cwd(), process.env.ENV_FILE || ".env"), +}); + +process.env.BUILD_OUT_ROOT = process.env.BUILD_OUT_ROOT || BUILD_OUT_ROOT; spawn(rariBin, ["build"], { stdio: "inherit" }); diff --git a/bins/tool.mjs b/bins/tool.mjs index b050ef3d176b..f12103c2a68e 100644 --- a/bins/tool.mjs +++ b/bins/tool.mjs @@ -2,4 +2,16 @@ import { rariBin } from "@mdn/rari"; import { spawn } from "cross-spawn"; +import { config } from "dotenv"; +import path from "node:path"; +import { cwd } from "node:process"; + +import { BUILD_OUT_ROOT } from "../libs/env/index.js"; + +config({ + path: path.join(cwd(), process.env.ENV_FILE || ".env"), +}); + +process.env.BUILD_OUT_ROOT = process.env.BUILD_OUT_ROOT || BUILD_OUT_ROOT; + spawn(rariBin, ["content"], { stdio: "inherit" }); diff --git a/package.json b/package.json index 0b768d983117..46220ef5eb9a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "scripts": { "ai-help-macros": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node scripts/ai-help-macros.ts", "analyze": "(test -f client/build/stats.json || cross-env ANALYZE_BUNDLE=true yarn build:client) && webpack-bundle-analyzer client/build/stats.json", - "build": "yarn rari build", + "build": "node bins/build.mjs", "build:client": "cd client && cross-env NODE_ENV=production BABEL_ENV=production node scripts/build.js", "build:dist": "tsc -p tsconfig.dist.json", "build:glean": "cd client && cross-env VIRTUAL_ENV=venv glean translate src/telemetry/metrics.yaml src/telemetry/pings.yaml -f typescript -o src/telemetry/generated", @@ -63,7 +63,7 @@ "test:libs": "yarn jest --rootDir libs --env=node", "test:prepare": "yarn build:prepare && yarn build && yarn render:html && yarn start:static-server", "test:testing": "yarn jest --rootDir testing", - "tool": "yarn rari content", + "tool": "node bins/tool.mjs", "tool:legacy": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node ./tool/cli.ts", "watch:ssr": "webpack --mode=production --watch --config=ssr/webpack.config.js" },