In the following post I will show an example where I use Bazel to build an Angular application and a nodejs api.
The application used for this demo is a modified version of Alex Eagle’s Bazel demo.
You can find the modified version here.
The application consists of two parts: An Angular application and a node express api.
I modified the original Angular application to make an http request to fetch a headline from the api.
The main component can be found below:
The application and Bazel build process is otherwise unchanged from the original setup.
The api is super simple as seen below:
The api is written in Typescript.
Next I am using the nodejs_binary rule to run the api after it’s transpiled.
The full BUILD.bazel file can be found below:
I now have two Bazel rules to build and run.
In order to run both at the same time I trigger parallel Bazel run commands by using concurrently.
I use an npm script task to wrap the two iBazel commands:
To run the project all you need is npm run start.
When you execute the command, both apps will start.
Since I am using iBazel the applications will refresh whenever any of the source files are modified.