-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
88 lines (78 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var gulp = require('gulp'),
sass = require('gulp-sass'),
livereload = require('gulp-livereload'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
watchify = require('watchify'),
browserifyConfig = {
entries : './client/js/app.js',
debug : true
}
;
function errorHandler (err) {
gutil.beep();
gutil.log(err.message || err);
}
gulp.task('sass', function () {
gulp.src('./public/scss/*.scss')
.pipe(plumber({
errorHandler: errorHandler
}))
.pipe(sass({
includePaths : [
'public/bower_components/bourbon/dist',
'public/bower_components/neat/app/assets/stylesheets',
'public/bower_components/font-awesome/scss'
],
outputStyle : (process.env.NODE_ENV === 'production') ? 'compressed' : 'nested'
}))
.pipe(plumber.stop())
.pipe(gulp.dest('./public/css'));
});
/**
* Task: `browserify`
* Bundle js with browserify
*/
gulp.task('browserify', function() {
browserify(browserifyConfig)
.transform('brfs')
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./public/js'));
});
/**
* Task: `watchify`
* Watch js and rebundle with browserify
*/
gulp.task('watchify', function() {
var bundler = watchify(browserify(browserifyConfig, watchify.args))
.transform('brfs')
.on('update', rebundle);
function rebundle () {
return bundler.bundle()
.on('error', errorHandler)
.pipe(source('bundle.js'))
.pipe(gulp.dest('public/js'));
}
});
gulp.task('lint', function() {
gulp.src(['./public/js/main.js', 'client/js/**/*.js', './*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('watch', ['watchify'], function(){
livereload.listen();
gulp.watch('./public/scss/**/*.scss', ['sass']);
gulp.watch(['./public/js/main.js', 'client/js/**/*.js', './*.js'], ['lint']);
gulp.watch(['./public/*.html', './public/js/*.js', './public/css/*.css'])
.on('change', livereload.changed);
});
gulp.task('default', function() {
// place code for your default task here
});
gulp.task('build', ['sass', 'browserify'], function() {
// place code for your default task here
});