-
-
Notifications
You must be signed in to change notification settings - Fork 58
Add a way to pass custom ENV variables. #1134
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
Conversation
swashata
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly make these changes. I think, in the client side code, we should use something like console.log(process.env.WPACKIO_ENV). That's how CRA does it.
| this.customEnv = {}; | ||
| Object.keys(process?.env || {}).forEach(key => { | ||
| if (key.startsWith('WPACKIO_')) { | ||
| this.customEnv[key] = JSON.stringify(process?.env?.[key]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I am wrong, but shouldn't this be
this.customEnv[`process.env.${key}`] = JSON.stringify(process?.env?.[key]);|
|
||
| // check in class | ||
| // @ts-ignore (since this is private). Check it's set. | ||
| expect(JSON.parse(cwc.customEnv.WPACKIO_ENV)).toBe('test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we change the key of customEnv, we need to update here too
expect(JSON.parse(cwc.customEnv['process.env.WPACKIO_ENV'])).toBe('test');|
Sorry for the delay on this. I ended up breaking my wrist and getting surgery, so typing is a pain. Hopefully I should be able to contribute in a few weks. |
|
No worries at all. Take rest and get well soon 🙂 |
|
This isn't needed anymore, since v6 has the functionality. |
This lets the user pass custom ENV variables to webpack's Define plugin. The variable must start with
WPACKIO_to be included to prevent leaking sensitive env variables client-side. 😁