forked from bozdoz/leaflet-freehandshapes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
81 lines (71 loc) · 2.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
var gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
uglify = require('gulp-uglify'),
browserSync = require('browser-sync').create(),
derequire = require('gulp-derequire');
gulp.task('default', ['watch']);
gulp.task('build-dev', function() {
return browserifyTemplate('./src/index.js', 'leaflet-freehandshapes.js', {
standalone : 'L.freeHandShapes'
})
.pipe(derequire())
.pipe(buffer())
.pipe(uglify({
mangle: false,
compress : false,
output : {
beautify : true
},
preserveComments: 'license'
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('build', ['build-dev'], function() {
return browserifyTemplate('./src/index.js', 'leaflet-freehandshapes.min.js', {
standalone : 'L.freeHandShapes'
})
.pipe(derequire())
.pipe(buffer())
.pipe(uglify({
preserveComments: 'license'
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('browserify-web-worker', function() {
return browserifyTemplate('./example/js/turf-web-worker.js', 'turf-web-worker.min.js')
.pipe(gulp.dest('./example/js/'));
});
gulp.task('browserify-example', ['build-dev', 'browserify-web-worker'], function() {
return browserifyTemplate('./example/js/script.js', 'main.js')
.pipe(gulp.dest('./example/js/'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('bs', ['browserify-example'], function() {
return browserSync.init({
server: {
baseDir: "./",
directory : true
},
startPath : "/example/index.html",
ui : false,
files : ['./**/*.html','./**/*.css']
});
});
gulp.task('watch', ['bs'], function() {
gulp.watch(['./src/*.js','./example/js/*.js',
'!./example/js/main.js', '!./example/js/turf-web-worker.min.js'], ['browserify-example']);
});
function browserifyTemplate (file, output, options) {
var options = options || {};
return browserify( file, options )
.bundle()
.on('error', errorHandler)
.pipe(source( output ));
}
function errorHandler (err) {
console.log( err );
browserSync.notify( err.message );
this.emit('end');
}