-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (77 loc) · 2.01 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var gulp = require('gulp');
var config = require('./config');
var plugins = require('gulp-load-plugins')({
rename: {
'gulp-autoprefixer': 'prefix',
'gulp-minify-css': 'minifyCSS',
'gulp-ng-html2js': 'html2js',
'gulp-livereload': 'livereload'
}
});
var onError = function(err) {
console.log(err);
this.emit('end');
};
var getTask = function(task) {
return require('./gulp/' + task)(gulp, plugins, config, onError);
};
var task = function(name, dependencies) {
if (dependencies) {
gulp.task(name, dependencies, getTask(name));
} else {
gulp.task(name, getTask(name));
}
};
task('jade-index');
task('less');
task('copy-vendor');
task('copy-assets');
task('clean');
task('templates');
task('min-js');
task('lint-client');
task('uglify', ['min-js']);
task('minify', ['less']);
task('inject-index', [
'jade-index',
'minify',
'copy-vendor'
]);
// Tasks
gulp.task('default', ['demon']);
gulp.task('build', function(cb) {
plugins.runSequence('clean', [
'min-js',
'inject-index',
'templates',
'copy-assets'
], cb);
});
gulp.task('demon', ['watch'],function() {
plugins.nodemon({
script: 'server/server.js',
ext: 'js html jade',
env: {
'NODE_ENV': 'development'
},
// tasks: ['lint']
})
.on('start', function() {
console.log('NODEMON: START');
})
.on('change', function() {
console.log('NODEMON: CHANGE');
})
.on('restart', function() {
console.log('restarted!');
});
});
gulp.task('watch', ['build'], function() {
plugins.livereload.listen();
gulp.watch(config.app.js, ['min-js']);
gulp.watch(config.app.watchLess, ['minify']);
gulp.watch(config.app.jade, ['templates']);
gulp.watch(config.app.index, ['inject-index']);
gulp.watch(config.app.assets, ['copy-assets']);
gulp.watch(['config.js'], ['copy-vendor', 'inject-index'])
});