-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
35 lines (30 loc) · 971 Bytes
/
gulpfile.js
File metadata and controls
35 lines (30 loc) · 971 Bytes
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
/**
* This configuration taken from
* https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md
**/
var gulp = require('gulp');
var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
var browserify = require('browserify');
var hbsfy = require('hbsfy');
hbsfy.configure({
extensions: ['hbs']
});
function bundle() {
return bundler.transform(hbsfy)
.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('main.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
}
var bundler = watchify(browserify(watchify.args));
bundler.add('./src/main.js');
bundler.on('update', bundle);
bundler.on('log', gutil.log);
gulp.task('default', bundle); // run `gulp` to build & watch