-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
109 lines (94 loc) · 3.32 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
$ = require('gulp-load-plugins')(),
reactify = require('reactify');
function onError(e) {
console.log("SASS Error>>", e);
}
gulp.task('devtool-sass', [], function() {
return gulp.src('./src/devtool/css/panel.scss')
.pipe($.plumber({ errorHandler: onError }))
.pipe($.rubySass())
.pipe(gulp.dest('./devtool/'));
});
gulp.task('build-simflux', [], function () {
return browserify('./src/vizone/patches/simflux-viz.js')
.external('simflux')
.bundle()
.pipe(source('simflux-viz-bundle.js'))
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./demo-gauntlet'))
.pipe(gulp.dest('./demo'));
});
gulp.task('build1', [], function () {
// packaged without zone.js
return browserify('./src/vizone/index.js')
.external('simflux')
.external('zone.js')
.external('zone')
.bundle()
.pipe(source('vizone-build1.js'))
.pipe(gulp.dest('./tmp'))
});
gulp.task('build', ['build1'], function () {
// packaged with zone.js
return gulp.src(['./src/zone-patch/zone-pre.js.part', './node_modules/zone.js/zone.js', './src/zone-patch/zone-post.js.part', './tmp/vizone-build1.js'])
.pipe($.concat('vizone-bundle.js'))
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./demo-gauntlet'))
.pipe(gulp.dest('./demo'));
});
function browserifyDevtool(file) {
var outFile = file.replace('.jsx', '.js').replace('./src/devtool/js/', './devtool/js/');
return function () {
return browserify()
.transform(reactify, { harmony: true })
.add(file)
.bundle()
.pipe(source(outFile))
.pipe(gulp.dest('./'))
}
}
var devtoolFilesToCompile = [
'./src/devtool/js/panel.jsx',
'./src/devtool/js/bridge.js'
],
devtoolFilesDontCopy = devtoolFilesToCompile.map(function (f) {
return '!'+f;
}),
devtoolCompileTasks = [];
gulp.task('devtool-copy', function () {
gulp.src(['./src/devtool/**/*', '!./src/devtool/**/*.scss'].concat(devtoolFilesDontCopy))
.pipe(gulp.dest('./devtool'));
});
devtoolCompileTasks = devtoolFilesToCompile.map(function (file,i) {
var taskName = 'devtool-compile'+i;
gulp.task(taskName, browserifyDevtool(file));
return taskName;
});
gulp.task('build-devtool', ['devtool-sass','devtool-copy'].concat(devtoolCompileTasks));
gulp.task('zip', ['build', 'build-devtool'], function() {
var manifest = require('./src/devtool/manifest'),
distFileName = manifest.name + ' v' + manifest.version + '.zip',
mapFileName = manifest.name + ' v' + manifest.version + '-maps.zip';
//collect all source maps
//gulp.src('build/scripts/**/*.map')
// .pipe($.zip(mapFileName))
// .pipe(gulp.dest('dist'));
//build distributable extension
return gulp.src(['devtool/**', '!devtool/**/*.map'])
.pipe($.zip(distFileName))
.pipe(gulp.dest('dist'));
});
gulp.task('build-gauntlet', ['build', 'build-devtool'], function () {
return browserify('./demo-gauntlet/src/app.jsx')
.transform(reactify, { harmony: true })
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./demo-gauntlet'))
});
gulp.task('watch', ['default'], function() {
gulp.watch('./**/*', ['build', 'build-simflux', 'build-devtool']);
});
gulp.task('default', ['build', 'build-simflux', 'build-devtool']);