-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
57 lines (49 loc) · 1.48 KB
/
gulpfile.js
File metadata and controls
57 lines (49 loc) · 1.48 KB
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
'use strict';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
jshintStylish = require('jshint-stylish'),
minifyCSS = require('gulp-minify-css'),
mochaPhantomJS = require('gulp-mocha-phantomjs'),
rimraf = require('rimraf'),
stripCode = require('gulp-strip-code'),
uglify = require('gulp-uglify');
// Hint our javascript code
gulp.task('jshint', function() {
return gulp.src('js/**')
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish));
});
// Minify and strip test code from javascript files (sadly the gulp-strip-code options fail our jscs rules :( )
gulp.task('uglify', function() {
return gulp.src('js/**')
.pipe(stripCode({
start_comment: 'start-test-code',
end_comment: 'end-test-code'
}))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest('build'));
});
// Minify css
gulp.task('css', function() {
return gulp.src('css/**')
.pipe(minifyCSS())
.pipe(gulp.dest('build'));
});
// Run our JavaScript tests
gulp.task('test', function() {
return gulp
.src('test/runner.html')
.pipe(mochaPhantomJS({reporter: 'spec'}));
});
// Build our code ready for production
gulp.task('build', ['jshint', 'test', 'uglify', 'css']);
// Clean out the build directory and trigger a fresh build
gulp.task('clean', function() {
rimraf('build', function() {
gulp.start('build');
});
});
// Watch our JavaScript files for changes and run our tests when something changes
gulp.task('watch', function() {
gulp.watch(['test/*.js', 'js/*.js'], ['jshint', 'test']);
});