Server done, need to open browser on 0.0.0.0 and check livereload
diff --git a/xos/core/xoslib/xos-builder/bower.json b/xos/core/xoslib/xos-builder/bower.json
index f17c808..9bbcec4 100644
--- a/xos/core/xoslib/xos-builder/bower.json
+++ b/xos/core/xoslib/xos-builder/bower.json
@@ -21,5 +21,8 @@
"angular-cookies": "~1.4.7",
"angular-resource": "~1.4.7",
"ng-lodash": "~0.3.0"
+ },
+ "devDependencies": {
+ "bootstrap-css": "2.3.2"
}
}
diff --git a/xos/core/xoslib/xos-builder/gulp/server.js b/xos/core/xoslib/xos-builder/gulp/server.js
index 443909b..b5de56a 100644
--- a/xos/core/xoslib/xos-builder/gulp/server.js
+++ b/xos/core/xoslib/xos-builder/gulp/server.js
@@ -7,22 +7,52 @@
var angularFilesort = require('gulp-angular-filesort');
var babel = require('gulp-babel');
var wiredep = require('wiredep').stream;
+var httpProxy = require('http-proxy');
-module.exports = function(options){
- gulp.task('browser', function() {
- browserSync.init({
- server: {
- baseDir: options.src
- }
- });
+var proxy = httpProxy.createProxyServer({
+ target: 'http://0.0.0.0:9000'
+});
+
+
+proxy.on('error', function(error, req, res) {
+ res.writeHead(500, {
+ 'Content-Type': 'text/plain'
});
+ console.error('[Proxy]', error);
+});
+
+module.exports = function(options){
+
+ // open in browser with sync and proxy to 0.0.0.0
+ gulp.task('browser', function() {
+ browserSync.init({
+ reloadDelay: 500,
+ server: {
+ baseDir: options.src,
+ middleware: function(req, res, next){
+ console.log(req.url);
+ if(req.url.indexOf('no_hyperlinks') !== -1){
+ proxy.web(req, res);
+ }
+ else{
+ next();
+ }
+ }
+ }
+ });
+
+ gulp.watch(options.scripts + '**/*.js', ['js-watch']);
+ });
+
+ // transpile js with sourceMaps
gulp.task('babel', function(){
return gulp.src(options.scripts + '**/*.js')
.pipe(babel({sourceMaps: true}))
.pipe(gulp.dest(options.tmp));
});
+ // inject scripts
gulp.task('inject', ['babel'],function(){
return gulp.src(options.src + 'index.html')
.pipe(
@@ -37,17 +67,22 @@
.pipe(gulp.dest(options.src));
});
+ // inject bower dependencies with wiredep
gulp.task('bower', function () {
gulp.src(options.src + 'index.html')
- .pipe(wiredep())
+ .pipe(wiredep({devDependencies: true}))
.pipe(gulp.dest(options.src));
-});
+ });
+
+ //watch js for changes
+ gulp.task('js-watch', ['babel'], browserSync.reload);
gulp.task('serve', function() {
runSequence(
'bower',
'inject',
- 'browser'
+ ['browser'
+ ]
);
});
}
\ No newline at end of file
diff --git a/xos/core/xoslib/xos-builder/package.json b/xos/core/xoslib/xos-builder/package.json
index 15189e3..370fac6 100644
--- a/xos/core/xoslib/xos-builder/package.json
+++ b/xos/core/xoslib/xos-builder/package.json
@@ -26,6 +26,8 @@
"gulp-minify-html": "^1.0.4",
"gulp-ngmin": "^0.3.0",
"gulp-uglify": "^1.4.2",
+ "http-proxy": "^1.12.0",
+ "proxy-middleware": "^0.15.0",
"run-sequence": "^1.1.4",
"wiredep": "^3.0.0-beta",
"wrench": "^1.5.8"
diff --git a/xos/core/xoslib/xos-builder/src/index.html b/xos/core/xoslib/xos-builder/src/index.html
index 711270a..a383b6a 100644
--- a/xos/core/xoslib/xos-builder/src/index.html
+++ b/xos/core/xoslib/xos-builder/src/index.html
@@ -1,4 +1,5 @@
<!-- bower:css -->
+<link rel="stylesheet" href="vendor/bootstrap-css/css/bootstrap.css" />
<!-- endbower -->
<div ng-app="xos.contentProviderApp">
@@ -11,6 +12,7 @@
<script src="vendor/angular-cookies/angular-cookies.js"></script>
<script src="vendor/angular-resource/angular-resource.js"></script>
<script src="vendor/ng-lodash/build/ng-lodash.js"></script>
+<script src="vendor/bootstrap-css/js/bootstrap.js"></script>
<!-- endbower -->
<!-- inject:js -->
<script src="/.tmp/xosContentProvider.js"></script>
diff --git a/xos/core/xoslib/xos-builder/src/js/xosContentProvider.js b/xos/core/xoslib/xos-builder/src/js/xosContentProvider.js
index 180f5da..026d0ce 100644
--- a/xos/core/xoslib/xos-builder/src/js/xosContentProvider.js
+++ b/xos/core/xoslib/xos-builder/src/js/xosContentProvider.js
@@ -8,6 +8,8 @@
// - Add Es6 (Babel) and a build script
// - Autogenerate ngResource from swagger definition json
+console.log('ciao aabb');
+
angular.module('xos.contentProviderApp', [
'ngResource',
'ngRoute',