bento-codeing/netlify-plugin-use-env-in-runtime

Use `netlifyConfig.build.environment` instead of `process.env`

Closed this issue · 1 comments

Inside plugins, environment variables should be read using process.env but modified using netlifyConfig.build.environment. Modifying process.env works but has been deprecated.

For example:

module.exports = {
  onPreBuild: ({netlifyConfig}) => {
    // ...
    netlifyConfig.build.environment[key] = process.env[definition];
  }
};

Doing so will also automatically print a log message, which removes the need for:

https://github.com/ARKHN3B/netlify-plugin-use-env-in-runtime/blob/920ded63de5e0d9d9e8805ddb0041faeb730e7db/index.js#L30

Indeed, it's much better if I can have something that does the same job, that is not depreciated and that avoids me to manage the logs.

Once again, thank you for your feedback 😁

See correction.