-
-
Notifications
You must be signed in to change notification settings - Fork 621
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
feat: add built in .env support #4392
base: master
Are you sure you want to change the base?
Conversation
- Load env vars at build time and run time
|
||
const WebpackCLI = require("./webpack-cli"); | ||
|
||
const runCLI = async (args: Parameters<IWebpackCLI["run"]>[0]) => { | ||
// Load environment variables from .env files | ||
try { |
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.
I'm not sure that we want the env plugin to be default without any configuration. We should check if an env flag passed to the CLI/API is present.
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.
I added a --env-file
flag for loading in variables from env files into webpack.config.js
, but I've made the env plugin added by default so env vars can be accessed from bundled code without having to add the DotenvWebpackPlugin
.
Is this what you meant?
Add support for import.meta.env and introduce --env-file flag to load environment variables from .env files into the bundled files. - Support for import.meta.env in webpack builds - New --env-file CLI flag for specifying whether to load .env files for configuration - Renamed dotenv plugin for clarity
- Add documentation for the dotenv webpack plugin - Add --env-file flag to OPTIONS.md
What kind of change does this PR introduce?
Feature:
.env
file support following Vite's conventionsWEBPACK_
are exposed to Webpack-processed codewebpack.config.js
Did you add tests for your changes?
Will add
If relevant, did you update the documentation?
Will add
Summary
Closes #3747
Does this PR introduce a breaking change?
No
Other information
This is my first PR, so there'll probably be a few mistakes / many questions