Added support for live reload

pull/2/head
Keivan Beigi 10 years ago
parent 5af12b67be
commit 760469fc5f

@ -1,27 +1,31 @@
var gulp = require('gulp'); var gulp = require('gulp');
var print = require('gulp-print'); var print = require('gulp-print');
var cache = require('gulp-cached'); var cache = require('gulp-cached');
var livereload = require('gulp-livereload');
var paths = require('./paths.js'); var paths = require('./paths.js');
gulp.task('copyJs', function () { gulp.task('copyJs', function () {
return gulp.src( return gulp.src(
[ [
paths.src.root + "polyfills.js", paths.src.root + 'polyfills.js',
paths.src.root + "JsLibraries/handlebars.runtime.js", paths.src.root + 'JsLibraries/handlebars.runtime.js'
]) ])
.pipe(cache('copyJs')) .pipe(cache('copyJs'))
.pipe(print()) .pipe(print())
.pipe(gulp.dest(paths.dest.root)); .pipe(gulp.dest(paths.dest.root))
.pipe(livereload());
}); });
gulp.task('copyHtml', function () { gulp.task('copyHtml', function () {
return gulp.src(paths.src.html) return gulp.src(paths.src.html)
.pipe(cache('copyHtml')) .pipe(cache('copyHtml'))
.pipe(gulp.dest(paths.dest.root)); .pipe(gulp.dest(paths.dest.root))
.pipe(livereload());
}); });
gulp.task('copyContent', function () { gulp.task('copyContent', function () {
return gulp.src([paths.src.content + '**/*.*', '!**/*.less']) return gulp.src([paths.src.content + '**/*.*', '!**/*.less'])
.pipe(gulp.dest(paths.dest.content)); .pipe(gulp.dest(paths.dest.content))
.pipe(livereload());
}); });

@ -3,6 +3,7 @@ var handlebars = require('gulp-handlebars');
var declare = require('gulp-declare'); var declare = require('gulp-declare');
var concat = require('gulp-concat'); var concat = require('gulp-concat');
var wrap = require("gulp-wrap"); var wrap = require("gulp-wrap");
var livereload = require('gulp-livereload');
var path = require('path'); var path = require('path');
var streamqueue = require('streamqueue'); var streamqueue = require('streamqueue');
var stripbom = require('gulp-stripbom'); var stripbom = require('gulp-stripbom');
@ -47,6 +48,6 @@ gulp.task('handlebars', function () {
partialStream, partialStream,
coreStream coreStream
).pipe(concat('templates.js')) ).pipe(concat('templates.js'))
.pipe(gulp.dest(paths.dest.root))
.pipe(gulp.dest(paths.dest.root)); .pipe(livereload());
}); });

@ -1,6 +1,7 @@
var gulp = require('gulp'); var gulp = require('gulp');
var less = require('gulp-less'); var less = require('gulp-less');
var print = require('gulp-print'); var print = require('gulp-print');
var livereload = require('gulp-livereload');
var paths = require('./paths'); var paths = require('./paths');
var errorHandler = require('./errorHandler'); var errorHandler = require('./errorHandler');
@ -30,5 +31,6 @@ gulp.task('less', function () {
strictImports: true strictImports: true
})) }))
.on('error', errorHandler.onError) .on('error', errorHandler.onError)
.pipe(gulp.dest(paths.dest.content)); .pipe(gulp.dest(paths.dest.content))
.pipe(livereload());
}); });

@ -1,6 +1,5 @@
var gulp = require('gulp'); var gulp = require('gulp');
//var livereload = require('gulp-livereload'); var livereload = require('gulp-livereload');
var paths = require('./paths.js'); var paths = require('./paths.js');
@ -10,24 +9,12 @@ require('./less.js');
require('./copy.js'); require('./copy.js');
require('./webpack.js'); require('./webpack.js');
gulp.task('watch', ['jshint', 'handlebars', 'less', 'copyHtml', 'copyContent', 'copyJs'], function () {
gulp.task('watch', ['jshint', 'handlebars', 'less','copyHtml', 'copyContent','copyJs'], function () { livereload.listen();
gulp.start('webpackWatch'); gulp.start('webpackWatch');
gulp.watch([paths.src.scripts, paths.src.exclude.libs], ['jshint','copyJs']); gulp.watch([paths.src.scripts, paths.src.exclude.libs], ['jshint', 'copyJs']);
gulp.watch(paths.src.templates, ['handlebars']); gulp.watch(paths.src.templates, ['handlebars']);
gulp.watch([paths.src.less, paths.src.exclude.libs], ['less']); gulp.watch([paths.src.less, paths.src.exclude.libs], ['less']);
gulp.watch([paths.src.html], ['copyHtml']); gulp.watch([paths.src.html], ['copyHtml']);
gulp.watch([paths.src.content + '**/*.*', '!**/*.less'], ['copyContent']); gulp.watch([paths.src.content + '**/*.*', '!**/*.less'], ['copyContent']);
}); });
gulp.task('liveReload', ['jshint', 'handlebars', 'less', 'webPack'], function () {
var server = livereload();
gulp.watch([
'app/**/*.js',
'app/**/*.css',
'app/index.html',
'app/login.html'
]).on('change', function (file) {
server.changed(file.path);
});
});

@ -1,20 +1,15 @@
var gulp = require('gulp'); var gulp = require('gulp');
var gulpWebpack = require('webpack-stream');
var livereload = require('gulp-livereload');
var gulpWebpack = require('gulp-webpack');
var webpack = require('webpack');
var webpackConfig = require('../webpack.config'); var webpackConfig = require('../webpack.config');
webpackConfig.devtool = "#source-map"; webpackConfig.devtool = "#source-map";
gulp.task('webpack', function() { gulp.task('webpack', function() {
return gulp.src('main.js') return gulp.src('main.js').pipe(gulpWebpack(webpackConfig)).pipe(gulp.dest(''));
.pipe(gulpWebpack(webpackConfig, webpack))
.pipe(gulp.dest(''));
}); });
gulp.task('webpackWatch', function() { gulp.task('webpackWatch', function() {
webpackConfig.watch = true; webpackConfig.watch = true;
return gulp.src('main.js') return gulp.src('main.js').pipe(gulpWebpack(webpackConfig)).pipe(gulp.dest('')).pipe(livereload());
.pipe(gulpWebpack(webpackConfig, webpack))
.pipe(gulp.dest(''));
}); });

@ -23,6 +23,7 @@
"gulp-handlebars": "3.0.1", "gulp-handlebars": "3.0.1",
"gulp-jshint": "1.11.2", "gulp-jshint": "1.11.2",
"gulp-less": "3.0.3", "gulp-less": "3.0.3",
"gulp-livereload": "3.8.0",
"gulp-print": "1.1.0", "gulp-print": "1.1.0",
"gulp-replace": "0.5.3", "gulp-replace": "0.5.3",
"gulp-run": "1.6.8", "gulp-run": "1.6.8",
@ -34,7 +35,8 @@
"jshint-stylish": "2.0.1", "jshint-stylish": "2.0.1",
"run-sequence": "1.1.1", "run-sequence": "1.1.1",
"streamqueue": "1.1.0", "streamqueue": "1.1.0",
"tar.gz": "^0.1.1", "tar.gz": "0.1.1",
"webpack": "1.10.1" "webpack": "1.10.1",
"webpack-stream": "2.0.0"
} }
} }

Loading…
Cancel
Save