Skip to content

Comments

fix: allow NODE_ENV to override hardcoded production environment#2189

Open
raza-khan0108 wants to merge 1 commit intostyleguidist:masterfrom
raza-khan0108:fix/env-mismatch-babel-jsx
Open

fix: allow NODE_ENV to override hardcoded production environment#2189
raza-khan0108 wants to merge 1 commit intostyleguidist:masterfrom
raza-khan0108:fix/env-mismatch-babel-jsx

Conversation

@raza-khan0108
Copy link

@raza-khan0108 raza-khan0108 commented Jan 27, 2026

This PR fixes an issue where the environment was hardcoded to production in the build scripts, regardless of the system's NODE_ENV. This caused a mismatch between Styleguidist's Webpack config and other tools (like Babel) that rely on process.env.NODE_ENV.

In my specific case, this mismatch led to ReferenceError: _jsx is not defined because Babel was attempting to use a development-specific JSX transform while the build was forced into production mode.

Changes

src/scripts/make-webpack-config.ts: Updated to prioritize process.env.NODE_ENV over the default argument.
src/scripts/build.ts: Updated to check process.env.NODE_ENV before defaulting to 'production'.

Verification

Verified that running the build with NODE_ENV=development now correctly propagates the environment to loaders.
Verified that the default behavior (production build) remains unchanged when no environment variable is provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant