-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
77 lines (68 loc) · 2.31 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
var gulp = require('gulp'),
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
minifyCss = require('gulp-minify-css'),
rename = require("gulp-rename"),
replace = require('gulp-replace');
var config = {
cordova : {
src : 'src/cordova-index.html',
dest : 'www/'
},
chrome : {
src : 'src/chrome-index.html',
dest : 'chrome-app/'
}
};
// Default task
gulp.task('default', function () {
gulp.start(['cordova', 'chrome']);
});
gulp.task('cordova', function () {
index(config.cordova);
viewer(config.cordova);
images(config.cordova);
fonts(config.cordova);
books(config.cordova);
});
gulp.task('chrome', function () {
index(config.chrome);
viewer(config.chrome);
images(config.chrome);
fonts(config.chrome);
//books(config.chrome);
return gulp.src(['src/bower_components/zip.js/WebContent/z-worker.js', 'src/bower_components/zip.js/WebContent/inflate.js'])
.pipe(gulpif('*.js', uglify({mangle: false})))
.pipe(gulp.dest('chrome-app/js/'));
});
function index(cfg) {
return gulp.src(cfg.src)
.pipe(rename('index.html'))
.pipe(useref())
.pipe(replace('bower_components/zip.js/WebContent/', 'js/'))
.pipe(gulpif('*.js', uglify({mangle: false})))
.pipe(gulpif('*.css', minifyCss()))
.pipe(replace('../bower_components/material-design-icons/iconfont/MaterialIcons-Regular.woff2', '../fonts/MaterialIcons-Regular.woff2'))
.pipe(gulp.dest(cfg.dest));
}
function viewer(cfg) {
return gulp.src('src/viewer.html')
.pipe(useref())
.pipe(gulpif('*.js', uglify({mangle: false})))
.pipe(gulpif('*.css', minifyCss({processImport: false})))
.pipe(replace('../bower_components/material-design-icons/iconfont/MaterialIcons-Regular.woff2', '../fonts/MaterialIcons-Regular.woff2'))
.pipe(gulp.dest(cfg.dest));
}
function images(cfg) {
return gulp.src(['src/img/*'])
.pipe(gulp.dest(cfg.dest + 'img/'));
}
function fonts(cfg) {
return gulp.src(['src/bower_components/material-design-icons/iconfont/MaterialIcons-Regular.woff2'])
.pipe(gulp.dest(cfg.dest + '/fonts/'));
}
function books(cfg) {
return gulp.src(['src/books/**'])
.pipe(gulp.dest(cfg.dest + '/books/'));
}