forked from allartk/leaflet.offline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
58 lines (50 loc) · 1.4 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var uglify = require('gulp-uglify');
var connect = require('gulp-connect');
var path = require('path');
var rename = require('gulp-rename');
var pump = require('pump');
// shoud make a standalon js, without localforage
gulp.task('js', function () {
var b = browserify([
'./src/leaflet.offline.js',
], {
'transform': ['browserify-shim']
});
return b.external('localforage')
.bundle()
.pipe(source('leaflet.offline.js'))
.pipe(buffer())
.pipe(gulp.dest('./dist/'))
.pipe(connect.reload());
});
gulp.task('minify', ['js'], function (cb) {
pump([
gulp.src(['dist/*.js', '!dist/*.min.js']),
uglify(),
rename({suffix: '.min'}),
gulp.dest('./dist/')
], cb);
});
// should make node entry, see https://github.com/Leaflet/Leaflet/tree/v1.0.2/dist
gulp.task('src', function () {
gulp.src('src/**/*.js')
.pipe(concat('leaflet.offline-src.js'))
.pipe(gulp.dest('./dist/'))
.pipe(connect.reload());
});
gulp.task('example', ['js'], function () {
connect.server({
root: ['./',
path.dirname(require.resolve('localforage')),
path.dirname(require.resolve('leaflet.vectorgrid'))
],
livereload: true
});
gulp.watch('./src/**/*.js', ['js']);
});
gulp.task('release', ['minify']);