Does dotenv-webpack provide all environment variables from .env to front-end?

I am creating a public key application for some APIs and private keys for other APIs. I would like to save them all in my only file .envand use dotenvto provide private keys to my server and dotenv-webpackto provide public keys to my public javascript interface. Will I use this package so that my private keys are available in my javascript or will it only accept those that it needs?

Example:

# .env file
public_key="12345"
private_key="45678"

This needs to be accessed at the end of fron

// javascript file on front end
var publicKey = process.env.public_key

But I would like to leave this hidden

// javascript file in node.js
var privateKey = process.env.private_key

The package that I am considering is as follows: https://www.npmjs.com/package/dotenv-webpack

+4
1

github , :

dotenv-webpack dotenv Webpack.DefinePlugin. , DefinePlugin. , DefinePlugin, process.env.

.env . - dotenv-webpack .

, . , .

+3

Source: https://habr.com/ru/post/1666810/


All Articles