Skip to content

gatsby build forces NODE_ENV=production regardless of externally setting #31802

Answered by LekoArts
jonmadison asked this question in Help
Discussion options

You must be logged in to vote

Hi!

We won't change the behavior you're seeing. If you want to use .env.development also for production builds you'll need to use another env var to choose, e.g.

// gatsby-config.js

const activeEnv = process.env.ACTIVE_ENV || process.env.NODE_ENV

require('dotenv').config({ path: `.env.${activeEnv}` })

And then for a local:build script you'd use: ACTIVE_ENV=development gatsby build

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@jonmadison
Comment options

@Nowaker
Comment options

@jonmadison-amzn
Comment options

Answer selected by jonmadison
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #31776 on June 07, 2021 08:06.