add git gulp and browser-sync which still is not working properly
This commit is contained in:
57
gulpfile.js
57
gulpfile.js
@@ -1,7 +1,16 @@
|
||||
var gulp = require('gulp'),
|
||||
bower = require('bower-main-files'),
|
||||
inject = require('gulp-inject');
|
||||
debug = require('debug')('freecc:gulp'),
|
||||
bower = require('bower-main-files'),
|
||||
nodemon = require('gulp-nodemon'),
|
||||
sync = require('browser-sync'),
|
||||
reload = sync.reload,
|
||||
inject = require('gulp-inject'),
|
||||
reloadDelay = 7000;
|
||||
|
||||
var paths = {
|
||||
server: './app.js',
|
||||
serverIgnore: [],
|
||||
}
|
||||
gulp.task('inject', function() {
|
||||
gulp.src('views/home.jade')
|
||||
.pipe(inject(gulp.src(bower()), {
|
||||
@@ -10,4 +19,48 @@ gulp.task('inject', function() {
|
||||
.pipe(gulp.dest('views'));
|
||||
});
|
||||
|
||||
gulp.task('serve', function(cb) {
|
||||
var called = false;
|
||||
nodemon({
|
||||
script: paths.server,
|
||||
ext: '.js',
|
||||
ignore: paths.serverIgnore,
|
||||
env: {
|
||||
'NODE_ENV': 'development',
|
||||
'DEBUG': 'freecc:*'
|
||||
}
|
||||
})
|
||||
.on('start', function() {
|
||||
if (!called) {
|
||||
called = true;
|
||||
setTimeout(function() {
|
||||
cb();
|
||||
}, reloadDelay);
|
||||
}
|
||||
})
|
||||
.on('restart', function(files) {
|
||||
if (files) {
|
||||
debug('Files that changes: ', files);
|
||||
}
|
||||
setTimeout(function() {
|
||||
debug('Restarting browsers');
|
||||
reload();
|
||||
}, reloadDelay);
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('sync', ['serve'], function() {
|
||||
sync.init(null, {
|
||||
proxy: 'http://localhost:3000',
|
||||
logLeval: 'debug',
|
||||
files: [
|
||||
'public/**/*',
|
||||
],
|
||||
port: 3001,
|
||||
open: true,
|
||||
browser: ['safari', 'google chrome'],
|
||||
reloadDelay: reloadDelay
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('default', ['serve', 'sync']);
|
||||
|
Reference in New Issue
Block a user