Open klyngen opened 2 years ago
Be aware that any Gatsby build is considered "production" ...only the interactive npm run dev
or gatsby develop
will be considered "development"
On some hosts you can use process.env.CONTEXT === "production"
But not all hosts. Please consider my Pull Request https://github.com/andrezimpel/gatsby-plugin-gdpr-cookies/pull/89/files I have survived by forking and applying my changes.
In the PR, I took the liberty of also do some refactoring :smile:
There are some big issues with this plugin and I want to help you guys.
lodash merge that makes it impossible to override environments
Environment-variables that will never exist:
First read this Then understand that the environment variables will not be available in prod. process.env.NODE_ENV and process.env.ENV will not be available. Runtime. During development this will work well but not in production. GATSBY_NODE_ENV will work.
Please make a better solution for seeing if we are in production. My suggestion is that you want tracking unless you are in a development environment. Make an environment-variable that says no-tracking. I will make a PR to your repo and you can use it as inspiration.
Pull request for your repo is here