-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
66 lines (59 loc) · 2.2 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
/*jshint node:true */
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var watchify = require('watchify');
var source = require('vinyl-source-stream');
var reactify = require('reactify');
var uglify = require('gulp-uglify');
var streamify = require('gulp-streamify');
// var sass = require('gulp-sass');
var concat = require('gulp-concat');
gulp.task('watchify', function(){
var bundler = browserify({
entries: ['./client/src/js/main.js'], // Only need initial file, browserify finds the deps
transform: [reactify], // We want to convert JSX to normal javascript
cache: {}, packageCache: {}, fullPaths: true // Requirement of watchify
});
var watcher = watchify(bundler);
return watcher
.on('update', function () { // When any files update
var updateStart = Date.now();
watcher.bundle() // Create new bundle that uses the cache for high performance
.pipe(source('main.js'))
// .pipe(streamify(uglify()))
.pipe(gulp.dest('./client/dist/'));
console.log('Updated!', (Date.now() - updateStart) + 'ms');
})
.bundle() // Create the initial bundle when starting the task
.pipe(source('main.js'))
// .pipe(streamify(uglify()))
.pipe(gulp.dest('./client/dist/'));
});
gulp.task('browserify', function(){
var bundler = browserify({
entries: ['./client/src/js/main.js'], // Only need initial file, browserify finds the deps
transform: [reactify], // We want to convert JSX to normal javascript
cache: {}, packageCache: {}, fullPaths: true // Requirement of watchify
});
return bundler
.bundle() // Create the initial bundle when starting the task
.pipe(source('main.js'))
// .pipe(streamify(uglify()))
.pipe(gulp.dest('./client/dist/'));
});
//gulp.task('sass', function () {
//gulp.src([
//'client/src/scss/main.scss'
//])
//.pipe(sass({
//errLogToConsole: false
//}))
//.pipe(concat('main.css'))
//.pipe(gulp.dest('./client/dist/'));
//});
gulp.task('watch', ['browserify'], function () {
// gulp.watch('./client/src/scss/**/*.scss', ['sass']);
gulp.watch('./client/src/js/**/*.js', ['watchify']);
});
gulp.task('default', ['browserify' ]);