Unbundling Spring (maven) bundled SPA (AngularJS)!

Time to move away from legacy code structure and use SPA’s the right way.

folder structure

“OK, so what is the problem with that?”

Obstacles when splitting them apart

My solution

npm install express --save-dev
npm install http-proxy-middleware --save-dev
...
"scripts": {
"start": "node server.js"
},
"main": "server.js",
...
var express = require('express');
var proxy = require('http-proxy-middleware');
var app = express();
app.use('/', express.static(__dirname + '/'));app.use('/<path-to-proxy>', proxy({target: process.env.PROXY_HOST, changeOrigin: true}));
app.use('/<another-path-to-proxy>', proxy({target: process.env.PROXY_HOST, changeOrigin: true}));
app.listen(8080, 'localhost');console.log("MyProject Server is Listening on port 8080");
PROXY_HOST=<host-name> npm start

Conclusion