Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way to handle environment #1

Closed
brice-noowu opened this issue Apr 26, 2022 · 1 comment
Closed

Better way to handle environment #1

brice-noowu opened this issue Apr 26, 2022 · 1 comment

Comments

@brice-noowu
Copy link

brice-noowu commented Apr 26, 2022

Hi, and first of all, thank you for your work !

I helped a friend of mine to setup this template andI noticed a small problem with the way you manage the different environments :
Actually, when you're on the production build, you first try to fetch localhost, and if it fails, you then try to fetch the correct build deployed on Netlify. To me, this is a problem because you have to wait for the localhost request to time out before getting the correct bundle (which can be up to 4 seconds !).

What I suggest would be to have two environements files (dev and prod) with the same variables declared but with the correct values according to the env (the main.js absolute urls) . You would then use the dev env file by default when developing, and swap it with the prod env file on build time, with the help of yarn build.

Of course, instead of files, you could just use a variable framed by an if :

let url;
if(prod){
  url = env.prod.url
}
else{
  url = env.dev.url
}

What do you think ?

@armandsalle
Copy link
Owner

Hey 👋 thank you for your feedback!

The actual solution is not the best I admit! I don't understand well your way to do it, can you make a PR to show me your way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants