-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (61 loc) · 2.21 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
var gulp = require('gulp'),
stylus = require('gulp-stylus'),
csso = require('gulp-csso'),
jade = require('gulp-jade'),
coffee = require('gulp-coffee'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
util = require('gulp-util'),
path = require('path'),
filelog = require('gulp-filelog'), // better task output
es = require('event-stream'),
plumber = require('gulp-plumber'),
jeet = require('jeet'),
nib = require('nib'),
browserSync = require('browser-sync').create();
gulp.task('browser-sync', function() {
browserSync.init({server: {baseDir: "dist/"}}); // browser auto-update on save
});
gulp.task('css', function() {
return es.merge(
gulp.src('src/assets/*.styl').
pipe(plumber( {handleError: errorHandler})). // prevents parse errors from breaking "watch" task
pipe(stylus({use: [nib(), jeet()]})), // compiles stylus files, adding plugins
gulp.src('src/assets/*.css')
).
pipe(csso()). // css compressor
pipe(gulp.dest('dist/assets/')).
pipe(browserSync.stream());
});
// see https://www.npmjs.com/package/gulp-sourcemaps to setup sourcemaps
gulp.task('js', function() {
return es.merge(
gulp.src('src/assets/*.coffee').pipe(coffee()),
gulp.src('src/assets/*.js')
).
pipe(uglify()). // minifier etc.
pipe(concat('all.min.js')).
pipe(gulp.dest('dist/assets/')).
pipe(browserSync.stream());
});
gulp.task('html', function() {
return gulp.src('src/*.jade').
pipe(plumber( {handleError: errorHandler})). // prevents parse errors from breaking "watch" task
pipe(jade({ pretty: true })). // compiles jade files
// add minifier?
pipe(gulp.dest('dist/')).
pipe(browserSync.stream());
});
gulp.task('watch', function () {
gulp.watch('src/assets/*.styl',['css']);
gulp.watch('src/assets/*.js',['js']);
gulp.watch('src/assets/*.coffee',['js']);
gulp.watch('src/*.jade',['html']);
});
gulp.task('default', ['watch','js','css','html','browser-sync']);
/* Helpers */
function errorHandler(err){
console.log(err.message);
this.end();
}