Read keys from ENV will increase bundle size
See original GitHub issueBug report
If we destructure more than one key from process.env
, all keys will append to bundle file.
# .env file
REACT_APP_NAME=BEHNAM
REACT_APP_SURNAME=MOHAMMADI
// app
const { REACT_APP_NAME, REACT_APP_SURNAME } = process.env;
What is the current behavior?
// bundle file
var e=Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_NAME:"BEHNAM",REACT_APP_SURNAME:"MOHAMMADI"}),t=e.REACT_APP_NAME,n=e.REACT_APP_SURNAME;
If the current behavior is a bug, please provide the steps to reproduce.
Just destructure more than 1 key from process.env
const { REACT_APP_NAME, REACT_APP_SURNAME } = process.env;
What is the expected behavior?
// bundle file
var t='BEHNAM',n='MOHAMMADI';
Other relevant information: webpack version: 4.41.2 Node.js version: 14.16.1 Operating System: macOS Additional tools: Create React App
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
JavaScript performance beyond bundle size - Nolan Lawson
But I believe we focus on bundle size first and foremost because it's easy to measure. That's not to say that bundle size...
Read more >Two Quick Ways To Reduce React App's Size In Production
File size Development v/s Production. 2. Serve gzipped file in production. You can dramatically reduce the size by gzipping the bundle.js.
Read more >Reading in environment variables from an environment file
Current environment variables with the same keys as in the env file can either be left untouched or overwritten with the override parameter....
Read more >Understanding React Native env variables - LogRocket Blog
Variables can play different roles in React Native. For example, you can use CSS variables in React Native to store and implement custom...
Read more >Environment variables - AWS Amplify Hosting
Environment variables are key-value pairs that are available at build time. These configurations can ... Add the environment variable to your build command....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@BradPrit09 in documentation we use directly
process.env.ENV_NAME
(maybe we should improve docs to avoid misleading here, so feel free to do it).You can use
process.env
insidewebpack.config.js
safelyYes, we had one. I have added this issue to
webpack 5
project board https://github.com/webpack/webpack/projects/5#card-43856731