-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
186 lines (146 loc) · 5.16 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
var gulp = require('gulp');
var sass = require('gulp-sass');
var jade = require('gulp-jade');
var notify = require('gulp-notify');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var streamify = require('gulp-streamify');
var filter = require('gulp-filter');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var mainBowerFiles = require('main-bower-files');
var browsersync = require('browser-sync');
var reload = browsersync.reload;
var scriptFilter = filter(['*.js', '*.coffee']);
var notScriptFilter = filter(['!*.js', '!*.coffee', '*']);
function swallowError(error) {
console.log(error.toString());
gutil.beep();
this.emit('end');
}
gulp.copy=function(src,dest){
return gulp.src(src, {base:"."})
.pipe(gulp.dest(dest));
};
var vendors =
{
// jquery: "./bower_components/jquery/dist/jquery.js",
// underscore: "./bower_components/underscore/underscore.js",
// backbone: "./bower_components/backbone/backbone.js",
// backbone_babysitter: "./bower_components/backbone.babysitter/lib/backbone.babysitter.js",
// backbone_wreqr: "./bower_components/backbone.wreqr/lib/backbone.wreqr.js",
// marionette: "./bower_components/marionette/lib/backbone.marionette.min.js",
marionette: "./bower_components/underscore/underscore.js",
reactjs: "./bower_components/react/react-with-addons.js",
reflux: "./bower_components/reflux/dist/reflux.js"
};
var vendor_files = [];
for (var vendor in vendors) {
vendor_files.push(vendors[vendor]);
}
var base = {
src : "./src",
dst : "./build"
};
var path = {
jade : {
src: base.src + '/jade/*.jade',
dst: base.dst
},
template : {
src: "",
dst: ""
},
vendor : {
dst : base.dst + "/js/vendor"
},
js : {
src: base.src + "/js",
dst: base.dst + "/js"
},
coffeescript : {
src: base.src + "/coffeescript",
dst: base.dst + "/js"
},
html : {
src: "",
dst: ""
},
};
//fire up browsersync server
gulp.task('browsersync',function(){
browsersync({
server : {
baseDir: base.dst
}
});
});
//bundle vendor js
gulp.task('vendor', function(){
var vendorFiles = gulp.src(vendor_files)
//.pipe(scriptFilter)
.pipe(concat('vendor.js'))
.pipe(gulp.dest(path.vendor.dst))
.pipe(uglify())
.pipe(rename("vendor.min.js"))
.pipe(gulp.dest(path.vendor.dst));
});
//vendor leaflet
gulp.task('vendor-leaflet', function(){
var basedir = './bower_components/leaflet/dist';
var vendordir = '/leaflet'
return gulp.src([ basedir + '/**/*', '!**/leaflet-src.js'], {base: basedir})
.pipe(gulp.dest(path.vendor.dst + vendordir));
});
//vendor prunecluster
gulp.task('vendor-prunecluster', function(){
var basedir = './bower_components/PruneCluster/dist';
var vendordir = '/prunecluster'
return gulp.src([ basedir + '/**/*.css', basedir + '/**/*.min.js', basedir + '/**/*.js.map' ], {base: basedir})
.pipe(gulp.dest(path.vendor.dst + vendordir));
});
gulp.task('vendor-jsonlayer', function(){
var basedir = './bower_components/leaflet-layerJSON/dist';
var vendordir = '/leaflet-layerJSON';
return gulp.src([ basedir + '/**/*.js'], {base: basedir})
.pipe(gulp.dest(path.vendor.dst + vendordir)).pipe(reload({stream : true}));
});
//compile apps
gulp.task('app', function() {
return browserify(path.coffeescript.src + '/main.coffee')
.transform("coffee-reactify")
//.transform("debowerify")
//.transform("hbsfy")
.bundle()
.on("error", swallowError)
.pipe(source('app.js'))
.pipe(streamify(concat('app.js')))
.pipe(gulp.dest(path.js.dst))
.pipe(streamify(uglify()))
.pipe(rename("app.min.js"))
.pipe(gulp.dest(path.js.dst))
.pipe(reload({stream : true}));
});
gulp.task('jade-index', function() {
return gulp.src(path.jade.src)
.pipe(jade({
pretty: true
}))
.on("error", swallowError)
.pipe(gulp.dest(path.jade.dst))
.pipe(reload({stream : true}));
});
gulp.task('jade', function() {
return gulp.src(path.src.jade)
.pipe(jade())
.pipe(gulp.dest(path.dst.html))
});
gulp.task('watch', function() {
gulp.watch("/Applications/AMPPS/www/biodesign/biodesign-frontend/bower_components/leaflet-layerJSON/dist/leaflet-layerjson.src.js" , ['vendor-jsonlayer']);
gulp.watch(path.jade.src, ['jade-index']);
gulp.watch(path.coffeescript.src + '/**/**/*.coffee', ['app']);
});
gulp.task('default', ['watch', 'browsersync']);
gulp.task('build-vendor', ['vendor','vendor-jsonlayer', 'vendor-prunecluster', 'vendor-leaflet']);