gatsby-plugin-gdpr-cookies icon indicating copy to clipboard operation
gatsby-plugin-gdpr-cookies copied to clipboard

This will not work in production

Open klyngen opened this issue 3 years ago • 3 comments

There are some big issues with this plugin and I want to help you guys.

  1. lodash merge that makes it impossible to override environments
  const options = { ...defaultOptions, ...pluginOptions }
  1. 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

klyngen avatar Sep 19 '22 07:09 klyngen

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"

doublejosh avatar Jan 31 '23 00:01 doublejosh

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.

klyngen avatar Jan 31 '23 09:01 klyngen

In the PR, I took the liberty of also do some refactoring :smile:

klyngen avatar Jan 31 '23 09:01 klyngen