fix: allow NODE_ENV to override hardcoded production environment#2189
Open
raza-khan0108 wants to merge 1 commit intostyleguidist:masterfrom
Open
fix: allow NODE_ENV to override hardcoded production environment#2189raza-khan0108 wants to merge 1 commit intostyleguidist:masterfrom
raza-khan0108 wants to merge 1 commit intostyleguidist:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.