Updated generator to read parent env config
diff --git a/views/ngXosViews/diagnostic/gulp/server.js b/views/ngXosViews/diagnostic/gulp/server.js
index 194bd45..fbc605b 100644
--- a/views/ngXosViews/diagnostic/gulp/server.js
+++ b/views/ngXosViews/diagnostic/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -35,12 +41,8 @@
module.exports = function(options){
- // open in browser with sync and proxy to 0.0.0.0
gulp.task('browser', function() {
browserSync.init({
- // reloadDelay: 500,
- // logLevel: 'debug',
- // logConnections: true,
startPath: '#/',
snippetOptions: {
rule: {
@@ -50,14 +52,13 @@
server: {
baseDir: options.src,
routes: {
- '/api': options.api,
- '/xosHelpers/src': options.helpers
+ '/xos/core/xoslib/static/js/vendor': options.helpers,
+ '/xos/core/static': options.static + '../../static/'
},
middleware: function(req, res, next){
if(
- req.url.indexOf('/xos/') !== -1 ||
- req.url.indexOf('/xoslib/') !== -1 ||
- req.url.indexOf('/hpcapi/') !== -1
+ req.url.indexOf('/?no_hyperlinks') !== -1 ||
+ req.url.indexOf('/api/') !== -1
){
if(conf.xoscsrftoken && conf.xossessionid){
req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
@@ -85,17 +86,21 @@
gulp.watch(`${options.sass}/**/*.scss`, ['sass'], function(){
browserSync.reload();
});
+
+ gulp.watch([
+ options.helpers + 'ngXosHelpers.js',
+ options.static + '../../static/xosNgLib.css'
+ ], function(){
+ browserSync.reload();
+ });
});
+ // compile sass
gulp.task('sass', function () {
return gulp.src(`${options.sass}/**/*.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(options.css));
});
-
- // gulp.task('sass:watch', function () {
- // gulp.watch('./sass/**/*.scss', ['sass']);
- // });
// transpile js with sourceMaps
gulp.task('babel', function(){
@@ -111,8 +116,7 @@
inject(
gulp.src([
options.tmp + '**/*.js',
- options.api + '*.js',
- options.helpers + '**/*.js'
+ options.helpers + 'ngXosHelpers.js'
])
.pipe(angularFilesort()),
{
@@ -128,7 +132,10 @@
return gulp.src(options.src + 'index.html')
.pipe(
inject(
- gulp.src(options.src + 'css/*.css'),
+ gulp.src([
+ options.src + 'css/*.css',
+ options.static + '../../static/xosNgLib.css'
+ ]),
{
ignorePath: [options.src]
}