-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
92 lines (83 loc) · 2.29 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
browserify = require('browserify'),
watchify = require('watchify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
rename = require('gulp-rename'),
assign = require('lodash').assign,
options;
options = {
browserify: {
entries: './browser/main.js',
debug: false
},
watchify: {
ignoreWatch: true
},
hbsfy: {
extensions: 'mu'
},
rename: {
extname: '.min.js'
},
jshintrc: {
server: './.jshintrc',
client: './client.jshintrc'
},
paths: {
lint: [
'./*.js',
'./bin/*',
'./lib/**/*.js',
'!./node_modules/',
'!./bower_components/',
],
felint: [
'./browser/**/*.js',
'!./public/js/',
'!./node_modules/',
'!./bower_components/',
],
bundleDest: './public/js/',
nowDest: './now/js/'
}
};
gulp.task('lint', function () {
return gulp.src(options.paths.lint)
.pipe(jshint(options.jshintrc.server))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('felint', function () {
return gulp.src(options.paths.felint)
.pipe(jshint(options.jshintrc.client))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('watchify', function () {
var w = watchify(browserify(assign({}, watchify.args, options.browserify, options.watchify)));
w.on('update', bundle.bind(this, w)); // on any dep update, runs the bundler
w.on('log', gutil.log); // output build logs to terminal
bundle(w);
});
gulp.task('browserify', function () {
var b = browserify(options.browserify);
bundle(b);
});
function bundle (b) {
b.transform('hbsfy', options.hbsfy);
return b.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(gulp.dest(options.paths.bundleDest))
.pipe(uglify())
.on('error', gutil.log)
.pipe(rename(options.rename))
.pipe(gulp.dest(options.paths.bundleDest))
.pipe(gulp.dest(options.paths.nowDest));
}
gulp.task('build', ['lint', 'felint', 'browserify'], function() {});
gulp.task('default', ['watchify'], function() {});