diff --git a/.npmignore b/.npmignore index 36ef933f9e0a..cae2584b5134 100644 --- a/.npmignore +++ b/.npmignore @@ -16,6 +16,7 @@ server/node_modules/ # This won't be relevant or needed once the content is gone. /content/files/en-us/ +/client/venv/ /deployer kumascript/tests testing/ @@ -43,3 +44,6 @@ jest.config.js *.test.js .storybook/ .nvmrc + +# Don't pack the build. +mdn-yari-*.tgz diff --git a/libs/env/index.d.ts b/libs/env/index.d.ts index 87fcf51e18e8..947a26e04e7f 100644 --- a/libs/env/index.d.ts +++ b/libs/env/index.d.ts @@ -1,4 +1,3 @@ -export const ROOT: string; export const BUILD_OUT_ROOT: string; export const DEFAULT_FLAW_LEVELS: string; export const FILES: string; diff --git a/libs/env/index.js b/libs/env/index.js index bc87fa3e0d01..d3c8a97599ee 100644 --- a/libs/env/index.js +++ b/libs/env/index.js @@ -1,18 +1,17 @@ import fs from "node:fs"; import path from "node:path"; +import { cwd } from "node:process"; import { fileURLToPath } from "node:url"; import dotenv from "dotenv"; import { VALID_FLAW_CHECKS } from "../constants/index.js"; -// Spread into two lines to get the ROOT path, -// to prevent Webpack from treating 'new URL("../..", import.meta.url)' as an import. -const currentDir = path.dirname(fileURLToPath(import.meta.url)); -export const ROOT = path.join(currentDir, "..", ".."); +const dirname = fileURLToPath(new URL(".", import.meta.url)); +const ROOT = path.join(dirname, "..", ".."); dotenv.config({ - path: path.join(ROOT, process.env.ENV_FILE || ".env"), + path: path.join(cwd(), process.env.ENV_FILE || ".env"), }); // ----- diff --git a/ssr/index.ts b/ssr/index.ts index ffff42b41e15..f73f37e3e7ec 100644 --- a/ssr/index.ts +++ b/ssr/index.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import { fileURLToPath } from "node:url"; import dotenv from "dotenv"; @@ -7,12 +8,10 @@ import { StaticRouter } from "react-router-dom/server"; import { App } from "../client/src/app"; import render from "./render"; -// This is necessary because the ssr.js is in dist/ssr.js -// and we need to reach the .env this way. +const dirname = fileURLToPath(new URL(".", import.meta.url)); + dotenv.config({ - path: fileURLToPath( - new URL("../" + (process.env.ENV_FILE || ".env"), import.meta.url) - ), + path: path.join(dirname, "..", process.env.ENV_FILE || ".env"), }); export function renderHTML(url, context) {