Troubles Setting Up Environment Variables - React

Hi everyone,
I have created my own React app (not using create-react-app) and all seems to be working fine but I am unable to setup some “environment variables” with Webpack.

env.

SECRET_KEY=xxxxxxxxxxxxxxxxx

webpack.config.js

const webpack = require('webpack');

...
plugins: [
  new webpack.DefinePlugin({
    'process.env.SECRET_KEY': JSON.stringify(process.env.SECRET_KEY)
  })
]

server.js

console.log(process.env.SECRET_KEY);

My result is always undefined. Could anyone help please?
Thank you all in advance.
Marcelo

First your file has to have dot infront like .env

You should look at this article, https://medium.com/@trekinbami/using-environment-variables-in-react-6b0a99d83cf5

Looks like you need dotenv package as well.