Integrate Angular in Spring Boot with Gradle
Having a Angular HTML5 single page application and a Spring Boot application, we would like to serve the complete Angular app from Spring Boot. This blog shows you a couple simple steps to get everything up and running: run NPM from Gradle, integrate the Gradle frontend build in the main build and support HTML5 mode in the ResourceHandler of Spring Boot.
Create a subdirectory called frontend
with the frontend code and build scripts (webpack, npm).
Let's assume our npm start
and npm run watch
output to the /frontend/dist/
directory.
First we need to make sure the frontend code is build when we run gradle build
on our project.
We can use the plugin gradle-node-plugin for this.
Go ahead and create a /frontend/build.gradle
file.