Added support for live reload

pull/3113/head
Keivan Beigi 9 years ago
parent 5af12b67be
commit 760469fc5f

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

@ -3,6 +3,7 @@ var handlebars = require('gulp-handlebars');
var declare = require('gulp-declare');
var concat = require('gulp-concat');
var wrap = require("gulp-wrap");
var livereload = require('gulp-livereload');
var path = require('path');
var streamqueue = require('streamqueue');
var stripbom = require('gulp-stripbom');
@ -47,6 +48,6 @@ gulp.task('handlebars', function () {
partialStream,
coreStream
).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 less = require('gulp-less');
var print = require('gulp-print');
var livereload = require('gulp-livereload');
var paths = require('./paths');
var errorHandler = require('./errorHandler');
@ -30,5 +31,6 @@ gulp.task('less', function () {
strictImports: true
}))
.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 livereload = require('gulp-livereload');
var livereload = require('gulp-livereload');
var paths = require('./paths.js');
@ -10,24 +9,12 @@ require('./less.js');
require('./copy.js');
require('./webpack.js');
gulp.task('watch', ['jshint', 'handlebars', 'less','copyHtml', 'copyContent','copyJs'], function () {
gulp.start('webpackWatch');
gulp.watch([paths.src.scripts, paths.src.exclude.libs], ['jshint','copyJs']);
gulp.watch(paths.src.templates, ['handlebars']);
gulp.watch([paths.src.less, paths.src.exclude.libs], ['less']);
gulp.watch([paths.src.html], ['copyHtml']);
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);
});
});
gulp.task('watch', ['jshint', 'handlebars', 'less', 'copyHtml', 'copyContent', 'copyJs'], function () {
livereload.listen();
gulp.start('webpackWatch');
gulp.watch([paths.src.scripts, paths.src.exclude.libs], ['jshint', 'copyJs']);
gulp.watch(paths.src.templates, ['handlebars']);
gulp.watch([paths.src.less, paths.src.exclude.libs], ['less']);
gulp.watch([paths.src.html], ['copyHtml']);
gulp.watch([paths.src.content + '**/*.*', '!**/*.less'], ['copyContent']);
});

@ -1,20 +1,15 @@
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');
webpackConfig.devtool = "#source-map";
gulp.task('webpack', function() {
return gulp.src('main.js')
.pipe(gulpWebpack(webpackConfig, webpack))
.pipe(gulp.dest(''));
return gulp.src('main.js').pipe(gulpWebpack(webpackConfig)).pipe(gulp.dest(''));
});
gulp.task('webpackWatch', function() {
webpackConfig.watch = true;
return gulp.src('main.js')
.pipe(gulpWebpack(webpackConfig, webpack))
.pipe(gulp.dest(''));
webpackConfig.watch = true;
return gulp.src('main.js').pipe(gulpWebpack(webpackConfig)).pipe(gulp.dest('')).pipe(livereload());
});

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

Loading…
Cancel
Save