-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (47 loc) · 1.27 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
var gulp = require('gulp');
var del = require('del');
var browserify = require('browserify');
var through2 = require('through2');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var path = require('path');
var paths = {
cascade : {
src: 'src/Cascade.js',
dist: 'dist',
},
types : {
src: 'src/types/*.js',
dist: 'dist/types',
},
dist : 'dist'
};
gulp.task('clean', function (cb) {
return del(paths.dist, {force: true}, cb);
});
function jsPreProcess(src){
return gulp.src(src)
.pipe(through2.obj(function(file, enc, next) {
var name = path.parse(file.path).name;
browserify(file.path, {
standalone : name.substr(0, 1).toUpperCase() + name.substr(1)
})
.bundle(function(err, res) {
err && console.log(err.stack);
file.contents = res;
next(null, file);
});
}))
}
gulp.task('js', ['clean'], function() {
return jsPreProcess(paths.cascade.src)
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename('cascade.js'))
.pipe(gulp.dest(paths.cascade.dist));
});
gulp.task('types', ['clean'], function() {
return gulp.src(paths.types.src)
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest(paths.types.dist));
});
gulp.task('default', ['js', 'types'], function() {});