-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
36 lines (30 loc) · 1.21 KB
/
gulpfile.js
File metadata and controls
36 lines (30 loc) · 1.21 KB
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
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 reactify = require('reactify');
var rename = require('gulp-rename');
var bundler = watchify(browserify('./lib/index.js', watchify.args));
bundler.require('./lib/brcraft.js')
// add any other browserify options or transforms here
bundler.transform(reactify)
bundler.transform('brfs');
gulp.task('js', bundle); // so you can run `gulp js` to build the file
bundler.on('update', bundle); // on any dep update, runs the bundler
bundler.on('log', gutil.log); // output build logs to terminal
function bundle() {
return bundler.bundle()
// log errors if they happen
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
// optional, remove if you dont want sourcemaps
// .pipe(buffer())
// .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
// .pipe(sourcemaps.write('./')) // writes .map file
//
.pipe(rename('app.bundle.js'))
.pipe(gulp.dest('./contents/js'));
}