From 1a311e6c21abdf4552234bf9fc6983971a782d8d Mon Sep 17 00:00:00 2001 From: edleeks87 Date: Tue, 26 Nov 2024 10:39:16 +0000 Subject: [PATCH] chore: build script no longer uses cross-env and args can be passed to build-storybook script --- scripts/build-storybook.js | 32 +++++++++++++++++++++++++++++++- scripts/build.js | 4 ++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/scripts/build-storybook.js b/scripts/build-storybook.js index f66550dfed..70f794b43d 100644 --- a/scripts/build-storybook.js +++ b/scripts/build-storybook.js @@ -2,11 +2,41 @@ const dotenv = require("dotenv"); const fs = require("fs"); const { execSync } = require("child_process"); +const whitelistArgs = [ + "-h", + "--help", + "-V", + "--version", + "-o", + "--output-dir", + "-c", + "--config-dir", + "--loglevel", + "--quiet", + "--debug", + "--debug-webpack", + "--stats-json", + "--docs", + "--test", + "--ci", + "--smoke-test", + "--preview-url", + "--force-build-preview", + "--disable-telemetry", + "--enable-crash-reports", + "--webpack-stats-json", +]; const envConfig = dotenv.parse(fs.readFileSync(".env")); process.env.STORYBOOK_BUILD = envConfig.STORYBOOK_BUILD; +const args = process.argv.slice(2); +const storybookArgs = args + .filter((arg) => whitelistArgs.includes(arg.split("=")[0])) + .join(" "); try { - execSync("storybook build -c .storybook", { stdio: "inherit" }); + execSync(`storybook build -c .storybook ${storybookArgs}`, { + stdio: "inherit", + }); } catch (error) { // eslint-disable-next-line no-console console.error("Failed to start the application:", error); diff --git a/scripts/build.js b/scripts/build.js index d56a119abd..b3e9d04e9f 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -33,7 +33,7 @@ async function run(bundle) { { cjs: "./lib", esm: "./esm", - }[bundle] + }[bundle], ); const babelArgs = [ @@ -48,7 +48,7 @@ async function run(bundle) { `"${ignore.join('","')}"`, ]; - const command = ["cross-env babel", ...babelArgs].join(" "); + const command = ["babel", ...babelArgs].join(" "); const { stderr } = await exec(command, { env: { ...process.env, ...env },