CMS Development

SaraRandolph
Teilnehmer/-in

Where to put .env file in CMS-React-Boilderplate?

lösung

I am working with a custom version of CMS-React-Boilderplate and I'm having a hard time accessing any .env variables. I've created a `.env` file in my root directory and I have tried access it with `process.env.REACT_APP_...` without any success. Has anyone had any sucess using a `.env` file with hubspot?

0 Upvotes
1 Akzeptierte Lösung
kierana
Lösung
Mitwirkender/Mitwirkende

Where to put .env file in CMS-React-Boilderplate?

lösung

To use process.env you're going to need to use the EnvironmentPlugin, if you want to use .env you'll need to use https://www.npmjs.com/package/dotenv-webpack


I'm guessing you're used to using create-react-app - the CMS React Boilerplate doesn't use CRA.

 

Lösung in ursprünglichem Beitrag anzeigen

4 Antworten
SaraRandolph
Teilnehmer/-in

Where to put .env file in CMS-React-Boilderplate?

lösung

Thank you both! I ended up using the dotenv-webpack package and putting it in my webpack.config.js. Thanks for your help 🙂

Kevin-C
Trendsetter/-in | Partner
Trendsetter/-in | Partner

Where to put .env file in CMS-React-Boilderplate?

lösung

Thanks @dennisedson 

 

Hey @SaraRandolph not sure how much help I can bring to the table here as I haven't used env variables with the cms boiler.

 

But have you tested in other environments? This seems to be a common issue with the env variables.

 

To expand I'm not sure if the CMS boiler is configured to use the env variables. I'd imagine it would be but you know what happens when you assume lol.

 

In an attempt to not leave you empty handed I did find these links that may help you trouble shoot:

create-react-app docs

more of the same with another test method

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
kierana
Lösung
Mitwirkender/Mitwirkende

Where to put .env file in CMS-React-Boilderplate?

lösung

To use process.env you're going to need to use the EnvironmentPlugin, if you want to use .env you'll need to use https://www.npmjs.com/package/dotenv-webpack


I'm guessing you're used to using create-react-app - the CMS React Boilerplate doesn't use CRA.

 

dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

Where to put .env file in CMS-React-Boilderplate?

lösung

Heyo @SaraRandolph !

Tagging in @Kevin-C and @kierana to get some help here 😀

0 Upvotes