okta / samples-js-angular

samples-js-angular
https://github.com/okta/samples-js-angular
Other
73 stars 149 forks source link

Question: how to install "env.js" in new project? #120

Open FuadEfendi opened 3 years ago

FuadEfendi commented 3 years ago

env.js will load environment from testenv.

I am newbie and cannot find any clue how it works... how to configure it for new project? "dotenv"?

Please document few words in README and here; thanks!

FuadEfendi commented 3 years ago

I found README in subfolder

FuadEfendi commented 3 years ago

but it is not enough... what about "env.js", any documentation?

oleksandrpravosudko-okta commented 3 years ago

@FuadEfendi env.js loads environment variables fromtestenv file in repository root - is this something that does not work for you?

FuadEfendi commented 3 years ago

It loads testenv in this repository and it works. But I created new repository from scratch, installed "dotenv", copied "env.js", and it doesn't work. Maybe some other dependency/configuration setting is missing?

oleksandrpravosudko-okta commented 3 years ago

No other configuration locations I'm aware of - perhaps testenv path (../) is off in your repo?

FuadEfendi commented 3 years ago

yes I know about relative "../"; it is fixed accordingly; I am just trying to find "who is calling env.js when I run command ng serve and cannot find, some magic. So I assumed it will run automatically, but it doesn't (in my separate project). But it runs in this project. dotenv or something else.

FuadEfendi commented 3 years ago

Hi @oleksandrpravosudko-okta,

So I found the answer. env.js is not used at all so changing ../ won't help. Perhaps it is something which could be used in some environments. Maybe with dotenv.

Instead, we are using extra-webpack.config.js:

// Read environment variables from "testenv". Override environment vars if they are already set.
const TESTENV = path.resolve(__dirname, '..', 'testenv');

Thank you!