-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
59 lines (53 loc) · 2.04 KB
/
gulpfile.js
File metadata and controls
59 lines (53 loc) · 2.04 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var gulp = require('gulp');
var source = require('vinyl-source-stream'); // Used to stream bundle for further handling
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var handleErrors = require('./handleErrors');
gulp.task('browserify', function() {
var bundler = browserify({
entries: ['./src/App.js'], // Only need initial file, browserify finds the deps
transform: [reactify], // We want to convert JSX to normal javascript
debug: true, // Gives us sourcemapping
cache: {}, packageCache: {}
});
bundler
.bundle() // Create the initial bundle when starting the task
.pipe(plumber())
.pipe(source('build.min.js'))
.pipe(gulp.dest('./public/js/'));
});
// Just running the two tasks
gulp.task('default', ['browserify']);
function handleError(err) {
notify.onError({
message: "<%= error.message %>"
}).apply(this, arguments);
this.emit('end');
}
/* gulp.task('browserify', function() {
var bundler = browserify({
entries: ['./src/App.js'], // Only need initial file, browserify finds the deps
transform: [reactify], // We want to convert JSX to normal javascript
debug: true, // Gives us sourcemapping
cache: {}, packageCache: {}
});
var watcher = watchify(bundler);
return watcher
.on('update', function () { // When any files update
var updateStart = Date.now();
console.log('Updating!');
watcher.bundle() // Create new bundle that uses the cache for high performance
.on('error', console.log)
.pipe(source('build.min.js'))
// This is where you add uglifying etc.
.pipe(gulp.dest('./public/js/'));
console.log('Updated!', (Date.now() - updateStart) + 'ms');
})
.bundle() // Create the initial bundle when starting the task
.pipe(plumber())
.pipe(source('build.min.js'))
.pipe(gulp.dest('./public/js/'));
});*/