Felipe S. Felipe S. - 9 days ago 4
AngularJS Question

How to setup structure with SpringBoot and Angular2?

I'm trying to use Angular2 with Springboot, but I can't set them together.

I first started a springboot project, and then tried to follow the Angular 2 Tour of Heroes by johnpapa and run

npm install
.

The structure looks like below:

Structure

I have the
/app
folder, and the
.js
are compiled to
resources/static/app/js
.

Problems:

1) The folder
resources/static/node_modules/
has lots of files. So when running
bootRun
, it gets really slow and sometimes can't even refresh the files. I believe I shouldn't put the node_modules there, but not sure..

2)
npm install
puts the files in
./node_modules
so currently I copied them to
static
folder. Should I just build the
node_modules
to
static
?

3) My structure looks hacky.. what is the best way to do it ?

How to set this structure? Also, please let me know if I should start using grunt/gulp or some other tool to make this easier.

Ps.: In case anyone is interested in the johnpapa's guide: johnpapa's angular2 guide

Answer

1) Remove node_modules from static folder. Your build process should bundle all the necessary modules. node_modules is used only during build.

2) Do not copy node_modules into static folder

3) Remove sources from static folder. That one is meant only for generated bundle + some static PROD files like index.html

Comments