Reputation: 761
I'm currently having a look at JHipster.
What I could not figure out is how JHipster handles environments like dev, testing and production.
This includes:
In angular-cli projects I'm used to environment specific configuration files (environment.dev.ts, environment.prod.ts) that can be defined at build (ng build --env prod) but since angular.cli does not seem to be the prefered way on JHipster there must be another solution to this.
So my questions is:
Upvotes: 2
Views: 6369
Reputation: 6842
If you are creating a standalone application or using the JHipster gateway bundle architecture, you can parameterize your Angular 2 app through webpack by using DefinePlugin
. I detailed the steps to this process here: Environment-based properties for Angular 2 App Served by Webpack?
Upvotes: 1
Reputation: 16294
JHipster packages the client within the server as an executable jar so there is no need for different API endpoints between different environments on client side as long as you use /api
.
On server side, JHipster uses Spring profiles which can be set dynamically and point to external configuration files (application*.yml
files). By default JHipster comes with 2 main profiles dev
and prod
, but there are also others like swagger
and no-liquibase
that you can combine with dev
or prod
. You can define your own profiles too.
If your client app needs to access some external API endpoints (e.g. Google) that are different between environments, you can do it in 2 ways:
- retrieve the active profiles from server API using /api/profile-info
and then initializes your endpoints in client code.
- create a new endpoint in server (e.g. /api/configuration
) to fetch your client configuration
Then there are 2 kind of builds triggered by maven/gradle profiles: dev and prod.
For a newcomer, the most important thing is probably to understand Spring Profiles and application properties, these are not specific to JHipster.
Upvotes: 1