Search code examples
angularplayframeworkintellij-14

integrate play server and Angular in IntelliJ


I want to integrate my Angular2 client with Play framework in IntelliJ but despite searching on documentation and google, I cannot find an answer.

1) I have written a backend CRUD application using Scala and Mongodb in Play framework on IntelliJ. The frontend was HTML/JQuery/CSS. The application would run on localhost:9000. 2) Later I decided to use Angular for client side using Angular plugin available in IntelliJ. But it seems to spawn a different server (not Play) which runs on localhost:4200.

I am clueless how to make the overall application which consists of Angular front end and play server backend.


Solution

  • You are right, Angular spawns a different server.

    https://angular.io/guide/quickstart

    The ng serve command launches the server, watches your files, and rebuilds the app as you make changes to those files.

    It's a good idea to separate the Angular app and the Play backend, so later you can deploy the projects separately. If you want to learn more about Angular deployment: https://angular.io/guide/deployment

    If you still want to bundle the Angular and Play Code, you have to include all Angular files in the play project and create a Play route that serves the index.html.