I've developed a Spring maven rest api for my project. For the client side, I'm using Angular2 with typescript. As new to Angular, referred angular website for the development, using npm and lite-server.
Now I need to make these two separate projects into a single project, by integrating the html,js,css files into my maven project, to deploy it in Tomcat server.
Project structure
Client side
Project
|__ app
|_ all app files
|__ node_modules
|__ typings
|__ index.html
|__ package.json
|__ style.css
|__ systemjs.config.js
|__ tsconfig.json
|__ typings.json
Server side
Project
|__ src/main
|__ java
|__ resources
|__ webapp
|__index.html
|__ pom.xml
All similar posts/blogs, i found suggest to update pom.xml with node etc. But what i need is,
How this can be done?
Run this command, npm run build
, in angular project root folder to create a dist
folder, containing production ready client side files. But got this error
missing script build
.
Tomcat application. To deploy an angular application in tomcat we need to build the application using the ng tool. For this demo, I am going to build a simple default angular application using below command. To create an angular application run the following command in command prompt as shown below.
At last used angular-cli. ng build --prod
creates a production ready build. Copied index.html and .js files under project folder in tomcat webapps (Or under Webcontent in eclipse).
Edited index.html as <base href = ".">
and it worked fine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With