Inject dev files in index.html
diff --git a/xos/core/xoslib/xos-builder/.gitignore b/xos/core/xoslib/xos-builder/.gitignore
index 0d7b211..5157e54 100644
--- a/xos/core/xoslib/xos-builder/.gitignore
+++ b/xos/core/xoslib/xos-builder/.gitignore
@@ -1,2 +1,3 @@
dist/
-src/vendor
\ No newline at end of file
+src/vendor
+.tmp
\ No newline at end of file
diff --git a/xos/core/xoslib/xos-builder/gulp/build.js b/xos/core/xoslib/xos-builder/gulp/build.js
index e9691ff..40136c8 100644
--- a/xos/core/xoslib/xos-builder/gulp/build.js
+++ b/xos/core/xoslib/xos-builder/gulp/build.js
@@ -23,11 +23,13 @@
var TEMPLATE_HEADER = '/*This code is autogenerated from the templates files */ angular.module("<%= module %>"<%= standalone %>).run(["$templateCache", function($templateCache) {';
module.exports = function(options){
-
+
+ // empty the dist folder
gulp.task('clean', function(){
- return del(['dist/**/*']);
+ return del([options.dist + '**/*']);
});
+ // compile and minify scripts
gulp.task('scripts', function() {
return gulp.src([
options.scripts + '**/*.js'
@@ -37,9 +39,10 @@
.pipe(angularFilesort())
.pipe(concat('xosContentProvider.js'))
.pipe(uglify())
- .pipe(gulp.dest('dist'));
+ .pipe(gulp.dest(options.dist));
});
+ // set templates in cache
gulp.task('templates', function(){
return gulp.src("./src/templates/*.html")
.pipe(templateCache({
@@ -50,24 +53,33 @@
.pipe(gulp.dest(options.scripts));
});
+ // copy js output to Django Folder
gulp.task('copyJs', function(){
return gulp.src('dist/xosContentProvider.js')
.pipe(gulp.dest('../static/js/'))
});
+ // copy vendor js output to Django Folder
gulp.task('copyVendor', function(){
return gulp.src('dist/xosNgVendor.js')
.pipe(gulp.dest('../static/js/vendor/'));
});
+ // minify vendor js files
gulp.task('wiredep', function(){
var bowerDeps = wiredep().js;
return gulp.src(bowerDeps)
.pipe(concat('xosNgVendor.js'))
.pipe(uglify())
- .pipe(gulp.dest('dist'));
+ .pipe(gulp.dest(options.dist));
});
+ // TODO vendor
+ // - define a list of common components (eg: angular, angular-route, ...)
+ // - find the difference between local components e common components
+ // - minify only the local
+ // - unify wiredep, filter and copyVendor task
+
gulp.task('build', function() {
runSequence(
'clean',
diff --git a/xos/core/xoslib/xos-builder/gulp/server.js b/xos/core/xoslib/xos-builder/gulp/server.js
index aeaa887..134fc62 100644
--- a/xos/core/xoslib/xos-builder/gulp/server.js
+++ b/xos/core/xoslib/xos-builder/gulp/server.js
@@ -3,19 +3,43 @@
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var inject = require('gulp-inject');
+var runSequence = require('run-sequence');
+var angularFilesort = require('gulp-angular-filesort');
+var babel = require('gulp-babel');
module.exports = function(options){
gulp.task('browser', function() {
browserSync.init({
server: {
- baseDir: "./src"
+ baseDir: options.src
}
});
});
- gulp.task('inject', function(){
- return gulp.src('./src/index.html')
- .pipe(inject(gulp.src('./src/js/**/*.js', {read: false})))
+ gulp.task('babel', function(){
+ return gulp.src(options.scripts + '**/*.js')
+ .pipe(babel({sourceMaps: true}))
+ .pipe(gulp.dest(options.tmp));
+ });
+
+ gulp.task('inject', ['babel'],function(){
+ return gulp.src(options.src + 'index.html')
+ .pipe(
+ inject(
+ gulp.src(options.tmp + '**/*.js')
+ .pipe(angularFilesort()),
+ {
+ ignorePath: options.src
+ }
+ )
+ )
.pipe(gulp.dest('./src'));
});
+
+ gulp.task('serve', function() {
+ runSequence(
+ 'inject',
+ 'browser'
+ );
+ });
}
\ No newline at end of file
diff --git a/xos/core/xoslib/xos-builder/gulpfile.js b/xos/core/xoslib/xos-builder/gulpfile.js
index 85d20ee..df133b1 100644
--- a/xos/core/xoslib/xos-builder/gulpfile.js
+++ b/xos/core/xoslib/xos-builder/gulpfile.js
@@ -4,13 +4,14 @@
var wrench = require('wrench');
var options = {
+ src: 'src/',
scripts: 'src/js/',
+ tmp: 'src/.tmp',
dist: 'dist/'
};
wrench.readdirSyncRecursive('./gulp')
.map(function(file) {
- console.log(file);
require('./gulp/' + file)(options);
});
diff --git a/xos/core/xoslib/xos-builder/src/index.html b/xos/core/xoslib/xos-builder/src/index.html
index 887ed04..800ee7e 100644
--- a/xos/core/xoslib/xos-builder/src/index.html
+++ b/xos/core/xoslib/xos-builder/src/index.html
@@ -3,4 +3,6 @@
</div>
<!-- inject:js -->
+<script src="/.tmp/xosContentProvider.js"></script>
+<script src="/.tmp/templates.js"></script>
<!-- endinject -->