-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
126 lines (108 loc) · 3.16 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var util = require('gulp-util');
var concat = require('gulp-concat');
var less = require('gulp-less');
var removeLogs = require('gulp-removelogs');
var del = require('del');
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
var jscs = require('gulp-jscs');
var stylish = require('gulp-jscs-stylish');
var jshint = require('gulp-jshint');
var paths = {
srcjs: ['public/src/**/*.js'],
js: ['public/src/**/*.js', 'tests/**/*.js'],
less: ['public/src/**/*.less'],
html: ['public/src/**/*.html', '!public/src/index.html'],
index: ['public/src/index.html'],
buildJS: ['dist/js/**/*.js'],
images: ['public/src/images/**/*']
};
var noop = function() {};
/* Gulp Tasks */
gulp.task('copyImages', function() {
return gulp.src(paths.images)
.pipe(gulp.dest('./public/dist/images'));
});
gulp.task('deletebuild', function(cb) {
return del('./public/dist', cb);
});
gulp.task('deletebowercomponents', function(cb) {
return del('./bower_components', cb);
});
gulp.task('html', function() {
return gulp.src(paths.html)
.pipe(gulp.dest('public/dist/views'));
});
gulp.task('copyIndex', function() {
return gulp.src(paths.index)
.pipe(gulp.dest('public/dist'));
});
gulp.task('removeLogs', function() {
return gulp.src(paths.srcjs)
.pipe(removeLogs())
.pipe(gulp.dest('src'));
});
gulp.task('less', function() {
return gulp.src(paths.less)
.pipe(less().on('error', function(err) {
util.log(err);
process.exit(1);
this.emit('end');
}))
.pipe(concat('master.css'))
.pipe(gulp.dest('public/dist/styles'));
});
// watch the file changes...
gulp.task('watch', function() {
gulp.watch(paths.js, ['js']);
gulp.watch(paths.html, ['html']);
gulp.watch(paths.index, ['copyIndex']);
gulp.watch(paths.less, ['less']);
});
gulp.task('productionJS', function() {
return gulp.src(paths.srcjs)
.pipe(jshint())
.pipe(jscs())
.pipe(concat('app.js'))
.pipe(rename({extname: '.min.js'}))
.pipe(uglify())
.pipe(gulp.dest('public/dist/js'));
});
gulp.task('js', function() {
return gulp.src(paths.srcjs)
.pipe(jshint())
.pipe(jscs())
.on('error', noop)
.pipe(stylish.combineWithHintResults())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(concat('app.js'))
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest('public/dist/js'));
});
gulp.task('jsLint', function() {
return gulp.src(paths.js)
.pipe(jshint())
.pipe(jscs())
.on('error', noop)
.pipe(stylish.combineWithHintResults())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('bower-installer', shell.task([
'bower-installer'
]));
// Gulp default function for proceed the gulp.
gulp.task('default', function() {
runSequence('html', 'copyIndex', 'copyImages', 'less', 'js', 'watch');
});
gulp.task('build', function(callback) {
runSequence('deletebuild', 'bower-installer', 'deletebowercomponents', 'productionJS', 'html',
'copyIndex', 'less', 'copyImages', endGulpDevelop);
function endGulpDevelop() {
callback();
process.exit(0);
}
});