Improved build - step 2
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/index.js b/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
index b790547..6ddbc6e 100755
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
@@ -41,18 +41,17 @@
{ name: config.name, author: {name:user.git.name(), email: user.git.email()} }
);
},
- indexDev: function(){
+ index: function(){
this.fs.copyTpl(
this.templatePath('src/index.html'),
this.destinationPath(`${this.config.get('folder')}/${config.name}/src/index.html`),
{ name: config.name }
);
},
- indexProd: function(){
- this.fs.copyTpl(
- this.templatePath('src/prod.html'),
- this.destinationPath(`${this.config.get('folder')}/${config.name}/src/xos${this._fistCharToUpper(config.name)}.html`),
- { name: config.name, fileName: this._fistCharToUpper(config.name) }
+ css: function(){
+ this.fs.copy(
+ this.templatePath('src/css/dev.css'),
+ this.destinationPath(`${this.config.get('folder')}/${config.name}/src/css/dev.css`)
);
},
mainJs: function(){
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
index 914a809..33dde1e 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
@@ -19,12 +19,17 @@
var angularFilesort = require('gulp-angular-filesort');
var _ = require('lodash');
var eslint = require('gulp-eslint');
+var inject = require('gulp-inject');
+var rename = require('gulp-rename');
module.exports = function(options){
- // empty the dist folder
+ // delete previous builded file
gulp.task('clean', function(){
- return del([options.dist + '**/*']);
+ return del(
+ [options.dashboards + 'xos<%= fileName %>.html'],
+ {force: true}
+ );
});
// compile and minify scripts
@@ -54,6 +59,20 @@
return gulp.src(options.src + 'xos<%= fileName %>.html')
.pipe(gulp.dest(options.dashboards));
});
+ // copy html index to Django Folder
+ gulp.task('copyHtml', ['clean'], function(){
+ return gulp.src(options.src + 'index.html')
+ .pipe(
+ inject(
+ gulp.src([
+ options.static + 'js/vendor/xos<%= fileName %>Vendor.js',
+ options.static + 'js/xos<%= fileName %>.js'
+ ])
+ )
+ )
+ .pipe(rename('xos<%= fileName %>.html'))
+ .pipe(gulp.dest(options.dashboards));
+ });
// minify vendor js files
gulp.task('wiredep', function(){
@@ -82,7 +101,6 @@
gulp.task('build', function() {
runSequence(
- 'clean',
'templates',
'babel',
'scripts',
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
index b1c1756..722eb58 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
@@ -74,7 +74,7 @@
});
// inject scripts
- gulp.task('inject', ['cleanTmp', 'babel'], function(){
+ gulp.task('injectScript', ['cleanTmp', 'babel'], function(){
return gulp.src(options.src + 'index.html')
.pipe(
inject(
@@ -92,6 +92,20 @@
.pipe(gulp.dest(options.src));
});
+ // inject CSS
+ gulp.task('injectCss', function(){
+ return gulp.src(options.src + 'index.html')
+ .pipe(
+ inject(
+ gulp.src(options.src + 'css/*.css'),
+ {
+ ignorePath: [options.src]
+ }
+ )
+ )
+ .pipe(gulp.dest(options.src));
+ });
+
// inject bower dependencies with wiredep
gulp.task('bower', function () {
return gulp.src(options.src + 'index.html')
@@ -110,7 +124,8 @@
gulp.task('serve', function() {
runSequence(
'bower',
- 'inject',
+ 'injectScript',
+ 'injectCss',
['browser']
);
});
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
index c4c5abb..05554d8 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
@@ -20,7 +20,6 @@
"dependencies": {},
"devDependencies": {
"browser-sync": "^2.9.11",
- "del": "^2.0.2",
"gulp": "^3.9.0",
"gulp-angular-filesort": "^1.1.1",
"gulp-angular-templatecache": "^1.8.0",
@@ -28,6 +27,7 @@
"gulp-concat": "^2.6.0",
"gulp-inject": "^3.0.0",
"gulp-minify-html": "^1.0.4",
+ "gulp-rename": "^1.2.2",
"gulp-uglify": "^1.4.2",
"http-proxy": "^1.12.0",
"proxy-middleware": "^0.15.0",
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/css/dev.css b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/css/dev.css
new file mode 100644
index 0000000..af92e84
--- /dev/null
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/css/dev.css
@@ -0,0 +1,5 @@
+[ng-app]{
+ position: absolute;
+ top: 100px;
+ left: 200px;
+}
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/index.html b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/index.html
index 6f07294..6d5ac94 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/index.html
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/index.html
@@ -1,19 +1,11 @@
<!-- browserSync -->
<!-- bower:css -->
<!-- endbower -->
+<!-- inject:css -->
+<!-- endinject -->
-<style>
- .container{
- position: absolute;
- top: 100px;
- left: 200px;
- }
-</style>
-
-<div class="container">
- <div ng-app="xos.<%= name %>">
+<div ng-app="xos.<%= name %>">
<div ui-view></div>
- </div>
</div>
<!-- bower:js -->
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/prod.html b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/prod.html
deleted file mode 100644
index 4f1fc20..0000000
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/prod.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<div ng-app="xos.<%= name %>">
- <div ui-view></div>
-</div>
-
-<link rel="stylesheet" href="{{ STATIC_URL }}/css/xosLib.css">
-<script src="{{ STATIC_URL }}js/vendor/xos<%= fileName %>Vendor.js"></script>
-<script src="{{ STATIC_URL }}js/xos<%= fileName %>.js"></script>
\ No newline at end of file