forked from rakannimer/react-google-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
93 lines (72 loc) · 2.69 KB
/
Copy pathgulpfile.js
File metadata and controls
93 lines (72 loc) · 2.69 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
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'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
minifyCSS = require('gulp-minify-css'),
fs = require('fs'),
webserver = require('gulp-webserver'),
buffer = require('vinyl-buffer'),
streamify = require('gulp-streamify'),
stringify = require('stringify'),
reactify = require('reactify'),
watchify= require('watchify'),
argv = require('yargs').argv,
gutil = require('gulp-util'),
notify = require('gulp-notify');
function handleError(task) {
return function(err) {
gutil.log(gutil.colors.red(err));
notify.onError(task + ' failed, check the logs..')(err);
};
}
gulp.task('examples', function() {
return browserify({entries:['./examples/src/example.js'], debug:true})
.transform(reactify)
.transform(stringify(['.html']))
.bundle()
.pipe(source('examples.min.js'))
.pipe(gulp.dest('./examples/dist/'))
.pipe(notify("Examples compiled"));
});
gulp.task('dist', function() {
return browserify({entries:['./src/index.js'], debug:true})
.transform(reactify)
.bundle()
.pipe(source('react-google-charts.min.js'))
.pipe(buffer()) // <----- convert from streaming to buffered vinyl file object
.pipe(uglify()) // now gulp-uglify works
.pipe(gulp.dest('./dist/'))
.pipe(notify("JS compiled"));
});
gulp.task('scripts', function() {
return browserify({entries:['./src/index.js'], debug:true})
.transform(reactify)
.bundle()
.pipe(source('react-google-charts.min.js'))
.pipe(gulp.dest('./dist/'))
.pipe(notify("JS compiled"));
}).on('error', handleError);
gulp.task('webserver', function() {
gulp.src('./examples')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true
}));
});
gulp.task('watch-scripts', ['scripts'], function() {
gulp.watch(['./src/*.js', './src/**/*.js'], ['scripts']).on('error', handleError);
});
gulp.task('default', ['scripts','watch-scripts'], function(){
gulp.start('webserver');
}).on('error',handleError)
gulp.task('ex', ['examples', 'watch-examples'], function(){
gulp.start('webserver');
});
gulp.task('watch-examples',['scripts', 'examples'], function() {
gulp.watch([ './examples/src/*.js' ], ['examples']).on('error', handleError);
});
gulp.task('build', ['scripts']);