diff --git a/gulpfile.js b/gulpfile.js index fb5c96c6..d7920653 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,6 +13,7 @@ var handlebars = require('gulp-handlebars'); var wrap = require('gulp-wrap'); var declare = require('gulp-declare'); var watch = require('gulp-watch'); +var connect = require('gulp-connect'); /* * Clean ups ./dist folder @@ -32,7 +33,7 @@ function templates() { return gulp .src(['./src/main/template/**/*']) .pipe(handlebars()) - .pipe(wrap('Handlebars.template(/*__DEFINING__*/<%= contents %>)')) + .pipe(wrap('Handlebars.template(<%= contents %>)')) .pipe(declare({ namespace: 'Handlebars.templates', noRedeclare: true, // Avoid duplicate declarations @@ -65,7 +66,8 @@ gulp.task('dist', ['clean'], function() { .pipe(uglify()) .pipe(rename({extname: '.min.js'})) .on('error', gutil.log) - .pipe(gulp.dest('./dist')); + .pipe(gulp.dest('./dist')) + .pipe(connect.reload()); }); /* @@ -80,7 +82,8 @@ gulp.task('less', ['clean'], function() { ]) .pipe(less()) .on('error', gutil.log) - .pipe(gulp.dest('./src/main/html/css/')); + .pipe(gulp.dest('./src/main/html/css/')) + .pipe(connect.reload()); }); @@ -106,10 +109,21 @@ gulp.task('copy', ['less'], function() { * Watch for changes and recompile */ gulp.task('watch', function() { - watch(['./src/**/*.{coffee,js,less}'], function() { + return watch(['./src/**/*.{coffee,js,less}'], function() { gulp.start('default'); }); }); +/* + * Live reload web server of `dist` +*/ +gulp.task('connect', function() { + connect.server({ + root: 'dist', + livereload: true + }); +}); + gulp.task('default', ['dist', 'copy']); +gulp.task('serve', ['connect', 'watch']) diff --git a/package.json b/package.json index cc3ce004..149f1582 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "gulp-clean": "^0.3.1", "gulp-coffee": "^2.2.0", "gulp-concat": "^2.4.3", + "gulp-connect": "^2.2.0", "gulp-declare": "^0.3.0", "gulp-handlebars": "^3.0.1", "gulp-less": "^2.0.1",