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

This will not work in production #88

Open
klyngen opened this issue Sep 19, 2022 · 3 comments
Open

This will not work in production #88

klyngen opened this issue Sep 19, 2022 · 3 comments

Comments

@klyngen
Copy link

klyngen commented Sep 19, 2022

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

@doublejosh
Copy link

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"

@klyngen
Copy link
Author

klyngen commented Jan 31, 2023

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
Copy link
Author

klyngen commented Jan 31, 2023

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

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

No branches or pull requests

2 participants