-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
Environment variables in preact #762
Comments
Nothing new, I use dotenv-safe, if you want I can send you a snipped for |
Thank you @ForsakenHarmony. Can you please do that ? |
const { parsed } = require('dotenv-safe').config();
export default function(config, env, helpers) {
// dotenv injection
const { plugin } = helpers.getPluginsByName(config, 'DefinePlugin')[0];
Object.assign(
plugin.definitions,
Object.keys(parsed).reduce(
(env, key) => ({
...env,
[`process.env.${key}`]: JSON.stringify(parsed[key]),
}),
{}
)
);
} |
I can't make it work. I tried the following: Click to see preact.config.js
Click to see preact.config.js
All these solutions have the same result, my env vars are undefined under
Any thoughts @ForsakenHarmony ? |
Well, I finally found out the problem in my setup. At the time of the writing, It seems that there is a difference between 2.x.x and 3.x.x that cause this silent error with the env vars handling. Fixed with |
This is not working, got undefined for one of my variables in env |
Is there a way to inject secret environment variables in preact ? I found an old issue. Is this still the preferred way ? Are there any new ways ? The issue lists two options 1) webpack 2) plugin.
#463
The text was updated successfully, but these errors were encountered: