Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set NODE_ENV env var to 'production' when building #348

Merged
merged 1 commit into from
Jul 6, 2016

Conversation

KyleAMathews
Copy link
Contributor

Fixes #337

There seems to be a few Webpack loaders that require this e.g.
sass-loader. We set NODE_ENV to production already inside Webpack e.g.
for React's optimizations but this PR is necessary for code outside
Webpack e.g. node code in Webpack loaders.

Fixes #337

There seems to be a few Webpack loaders that require this e.g.
sass-loader. We set NODE_ENV to production already *inside* Webpack e.g.
for React's optimizations but this PR is necessary for code *outside*
Webpack e.g. node code in Webpack loaders.
@KyleAMathews KyleAMathews merged commit 7b410f1 into master Jul 6, 2016
@oliverbenns
Copy link
Contributor

oliverbenns commented Dec 24, 2016

Would love to be able to set my own NODE_ENV, e.g. NODE_ENV=version1 gatsby build.

@KyleAMathews
Copy link
Contributor Author

@oliverbenns you generally don't want to override NODE_ENV as it has specific meaning e.g. many modules including React itself look at NODE_ENV to see if it is set to production to see if they should apply optimizations e.g. turning off dev checks. If you override that, your site will become significantly slower.

Want you want to do probably is use a different environment variable e.g. BUILD_VERSION=1 and then use the same technique as Gatsby core uses to make that env variable available to your frontend code

'process.env': {

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.

None yet

2 participants