Committed by
Gerrit Code Review
WEB GUI: livereload enabled for applications
Change-Id: Id267f4902499e378dc7cb471ec59174dbf4c35a3
Showing
1 changed file
with
5 additions
and
6 deletions
... | @@ -20,7 +20,7 @@ var proxy = httpProxy.createProxyServer({ | ... | @@ -20,7 +20,7 @@ var proxy = httpProxy.createProxyServer({ |
20 | }); | 20 | }); |
21 | 21 | ||
22 | var defaultViews = fs.readdirSync('./app/view/'); | 22 | var defaultViews = fs.readdirSync('./app/view/'); |
23 | -var viewNameMatcher = new RegExp(/\/onos\/ui\/app\/view\/(.+)\/.+\.js/); | 23 | +var viewNameMatcher = new RegExp(/\/onos\/ui\/app\/view\/(.+)\/.+\.(?:js|css|html)/); |
24 | 24 | ||
25 | proxy.on('upgrade', function (req, socket, head) { | 25 | proxy.on('upgrade', function (req, socket, head) { |
26 | console.log('[WS]: ', head); | 26 | console.log('[WS]: ', head); |
... | @@ -54,20 +54,19 @@ module.exports = { | ... | @@ -54,20 +54,19 @@ module.exports = { |
54 | 54 | ||
55 | 55 | ||
56 | var viewName = viewNameMatcher.exec(req.url); | 56 | var viewName = viewNameMatcher.exec(req.url); |
57 | - | ||
58 | if(!!viewName && defaultViews.indexOf(viewName[1]) === -1){ | 57 | if(!!viewName && defaultViews.indexOf(viewName[1]) === -1){ |
59 | // in this case it is an external application that extend the view | 58 | // in this case it is an external application that extend the view |
60 | - // so we redirect the request to the app folder | 59 | + // so we redirect the request to the app folder in case of .js, .css, .html |
61 | req.url = req.url.replace('/onos/ui/', '/apps/' + viewName[1] + '/app/src/main/resources/'); | 60 | req.url = req.url.replace('/onos/ui/', '/apps/' + viewName[1] + '/app/src/main/resources/'); |
62 | proxy.web(req, res); | 61 | proxy.web(req, res); |
63 | } | 62 | } |
64 | - // NOTE onos.js should not be proxied (require server side injection) | 63 | + // NOTE onos.js and index.html should not be proxied (require server side injection) |
65 | - else if(req.url.match(/.js$/) && req.url !== '/onos/ui/onos.js'){ | 64 | + else if(req.url.match(/(?:js|css|html)/) && req.url !== '/onos/ui/onos.js' && req.url !== '/onos/ui/index.html' && req.url !== '/onos/ui/nav.html'){ |
66 | // redirect onos base js files to the source folder | 65 | // redirect onos base js files to the source folder |
67 | req.url = req.url.replace('/onos/ui/', '/web/gui/src/main/webapp/'); | 66 | req.url = req.url.replace('/onos/ui/', '/web/gui/src/main/webapp/'); |
68 | proxy.web(req, res); | 67 | proxy.web(req, res); |
69 | } | 68 | } |
70 | - else{ | 69 | + else { |
71 | return next(); | 70 | return next(); |
72 | } | 71 | } |
73 | } | 72 | } | ... | ... |
-
Please register or login to post a comment