Skip to content

Commit

Permalink
Merge pull request #7094 from Sage/fix-build-script
Browse files Browse the repository at this point in the history
chore: build script no longer uses cross-env and args can be passed t…
  • Loading branch information
edleeks87 authored Nov 26, 2024
2 parents c645d41 + 1a311e6 commit 79cbb7b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
32 changes: 31 additions & 1 deletion scripts/build-storybook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function run(bundle) {
{
cjs: "./lib",
esm: "./esm",
}[bundle]
}[bundle],
);

const babelArgs = [
Expand All @@ -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 },
Expand Down

0 comments on commit 79cbb7b

Please sign in to comment.