-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (67 loc) · 1.99 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
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require('gulp-notify');
var browserSync = require('browser-sync');
var minifyCSS = require('gulp-minify-css');
var paths = {
src: 'src',
dist: 'dist'
};
gulp.task('lint', function() {
return gulp.src(paths.src + '/**/*.js')
.pipe(jscs())
.pipe(notify({
title: '✔ jscs passed',
message: 'Cheers for sticking to the coding guidelines.',
}))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(notify({
title: '✔ JSHint passed',
message: 'Crockford would be proud. Oh, wait.',
}))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('compress:js', function() {
return gulp.src(paths.src + '/**/*.js')
// Add a non-minified copy to the dist folder before compression
.pipe(gulp.dest(paths.dist))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(paths.dist))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('compress:css', function() {
return gulp.src(paths.src + '/**/*.css')
// Add a non-minified copy to the dist folder before compression
.pipe(gulp.dest(paths.dist))
.pipe(minifyCSS())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(paths.dist))
});
gulp.task('browser-sync', function() {
return browserSync({
server: {
baseDir: "./"
}
});
});
gulp.task('watch', function() {
gulp.watch(paths.src + '/**/*.js', ['lint', 'compress:js']);
gulp.watch(paths.src + '/**/*.css', ['compress:css']);
});
gulp.task('build', ['lint', 'compress:js', 'compress:css']);
gulp.task('default', ['build', 'watch']);