OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

All environment variables at the top of JS file (Hide them?)

  • Thread starter Thread starter Cookies
  • Start date Start date
C

Cookies

Guest
I am calling a few environment variables in a js file that I am calling in the root of my project. Everything is working as expected, but I have noticed one thing that seems off to me. If I go into the console and open up that js file from source then every environment variable is at the top of the js file where I called a few of them.

.js file

Code:
function myFunction() {
  //call some env vars here
  const var1 = import.meta.env.VAR_1;
  const var2 = import.meta.env.VAR_2;     
}

What it looks like in the console

Code:
import.meta.env = {
  "VAR_1": "VAR_1 Value",
  "VAR_2": "VAR_2 Value",
  "VAR_3": "VAR_3 Value",
  "VAR_4": "VAR_4 Value",
  "VAR_5": "VAR_5 Value",
  "VAR_6": "VAR_6 Value",
  "VAR_7": "VAR_7 Value",
  "VAR_8": "VAR_8 Value"
};

const var1 = import.meta.env.VAR_1;
const var2 = import.meta.env.VAR_2;

Is there a way to not have all of the environment variables print out at the top of the js file in the console? I would maybe expect the environment variables that are called in the js file to be at the top, but not every single one...

<p>I am calling a few environment variables in a js file that I am calling in the root of my project. Everything is working as expected, but I have noticed one thing that seems off to me. If I go into the console and open up that js file from source then every environment variable is at the top of the js file where I called a few of them.</p>
<p>.js file</p>
<pre><code>function myFunction() {
//call some env vars here
const var1 = import.meta.env.VAR_1;
const var2 = import.meta.env.VAR_2;
}
</code></pre>
<p>What it looks like in the console</p>
<pre><code>import.meta.env = {
"VAR_1": "VAR_1 Value",
"VAR_2": "VAR_2 Value",
"VAR_3": "VAR_3 Value",
"VAR_4": "VAR_4 Value",
"VAR_5": "VAR_5 Value",
"VAR_6": "VAR_6 Value",
"VAR_7": "VAR_7 Value",
"VAR_8": "VAR_8 Value"
};

const var1 = import.meta.env.VAR_1;
const var2 = import.meta.env.VAR_2;
</code></pre>
<p>Is there a way to not have all of the environment variables print out at the top of the js file in the console? I would maybe expect the environment variables that are called in the js file to be at the top, but not every single one...</p>
 
Top