4

In my Angular4 application i ejected the webpack config and used dotenv module to read from a .env file and use those config variables in the application. Since i updated to Angular6 the "ng eject" is depricated and i am using angular-cli. I am looking for a workaroud for this problem (either using a config file or system environment variables).

If i can make a reference in Spring Framework in the application.properties file

spring.datasource.username = ${MYSQL_DB_USERNAME}

MYSQL_DB_USERNAME is environment variable. I would like to use this behavior in environment.ts

4
  • environment.ts is a config file. And you're not telling which concrete problem you're trying to solve. Commented Jul 6, 2018 at 12:52
  • Yes but i want to use sensitive information without pushing it to the repo Commented Jul 6, 2018 at 12:55
  • If those sensitive info is in the generated JavaScript files, distributed to each and every user of the application, putting it in the repo won't really make it less secure. Commented Jul 6, 2018 at 12:57
  • This is just for development. This sensitive information will be served to the user after login. But since the login hasn't been implemented yet using .env file with configuration that is not uploaded to the repo is working fine. Commented Jul 6, 2018 at 13:26

1 Answer 1

1

I dont think you are able to do that unless maybe you are using SSR? Webpack for angular 6 at the moment is disabled, they said they would re-add with some customization but majority will be done in angular.json. so for now no ng eject.

I think the best approach might be to make a restApi call to your backend on bootstrap to load and retrieve any variables you may require.

Ng Eject: https://github.com/angular/angular-cli/issues/10618

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.