-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgulpfile.js
38 lines (32 loc) · 1 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
var gulp = require('gulp'),
prettyData = require('gulp-pretty-data'),
zip = require('gulp-zip');
// Minify krpano action
function minifyAction() {
function dry (file, cb) {
file.contents = new Buffer(String(file.contents).replace(/(<action.+?>)([\s\S]+?)(<\/action>)/ig, function (str, opentag, cnt, closetag) {
return opentag + cnt.replace(/\s*(^|[;,=!])\s*/g, "$1") + closetag;
}));
cb(null, file);
}
return require('event-stream').map(dry);
}
// Minify plugin xml
gulp.task('xml', function () {
return gulp.src('dev/arrows.xml')
.pipe(prettyData({type: 'minify'}))
.pipe(minifyAction())
.pipe(gulp.dest('arrows/example/'));
});
// Create downloadable zip for plugin page
gulp.task('zip', function () {
return gulp.src(['arrows/**', '!arrows/*.zip'], {base: '.'})
.pipe(zip('arrows.zip'))
.pipe(gulp.dest('arrows/'));
});
// Minify xml when modified
gulp.task('watch', function () {
gulp.watch('dev/arrows.xml', ['xml']);
});
gulp.task('make', ['xml', 'zip']);
gulp.task('default', ['watch']);