nwinch / webpack-dotenv-plugin

Use dotenv with webpack.
MIT License
53 stars 17 forks source link

Feature request: use dotenv-extended instead #16

Open vlindhol opened 7 years ago

vlindhol commented 7 years ago

dotenv-safe is great, but dotenv-extended has the same functionality PLUS the ability to set default values for env variables. This makes it easy to check in sensible defaults into git, and if you need to input sensitive values or just a different configuration, you can use .env as normal. I use it in almost all my projects, very handy.

alexkrautmann commented 7 years ago

@vlindhol I forked this project and modified it for dotenv-extended: https://github.com/Alex-Krautmann/webpack-dotenv-extended-plugin. It worked out well for me in a universal react application. I was able to define default env vars for development and production build modes, then have deployment-environment specific env vars as the main env:

new DotEnvExtendedPlugin({
    errorOnMissing: true,
    errorOnExtra: true,
    schema: './env/.env.schema',
    defaults: './env/.env.defaults.development',
    path: `./env/deploymentEnv/.env.${process.env.DEPLOYMENT_ENV || 'dev'}`,
}),

@nwinch I am happy to submit a PR if this is something you want.