forked from codrops/ElasticProgress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·62 lines (50 loc) · 1.36 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
var gulp = require('gulp')
var browserify = require('browserify')
var source = require('vinyl-source-stream')
var streamify = require('gulp-streamify')
var uglify = require('gulp-uglify')
var extend = require('extend')
var connect = require('gulp-connect')
var opener = require('opener');
function buildJS(options){
if(typeof options=="undefined") options={};
options=extend({
minify:false,
gsap:false,
},options);
var bundleStream=browserify('./src/main.js',{standalone:'ElasticProgress'});
if(!options.gsap){
bundleStream=bundleStream.ignore('gsap').ignore('jquery');
}
bundleStream=bundleStream
.bundle()
.on('error',function(e){
console.log(e.message)
})
bundleStream
.pipe(source('elastic-progress.js'))
.pipe(gulp.dest('./dist/'))
if(options.minify){
bundleStream
.pipe(source('elastic-progress.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('./dist/'))
}
}
gulp.task('js',function(){
buildJS({minify:true});
});
gulp.task('js:dev',function(){
buildJS({minify:false});
});
gulp.task('watch',['js:dev'],function(){
gulp.watch(['src/*.js','src/*.svg'],['js:dev']);
});
gulp.task('build',function(){
buildJS({minify:true,gsap:false});
});
gulp.task('connect', function() {
connect.server();
opener('http://localhost:8080/demo');
});
gulp.task('default', ['connect','watch']);