This repository has been archived by the owner on Jul 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
/
gulpfile.js
84 lines (72 loc) · 2.34 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
82
83
84
var gulp = require('gulp');
var gulpif = require('gulp-if');
var del = require('del');
var dom = require('gulp-dom');
// Allow jellyfin-web directory override
var WEB_DIR = process.env.JELLYFIN_WEB_DIR || 'node_modules/jellyfin-web/dist';
console.info('using jellyfin-web from', WEB_DIR);
var paths = {
assets: {
src: [
WEB_DIR + '/**/*',
'!' + WEB_DIR + '/index.html'
],
dest: 'www/'
},
index: {
src: WEB_DIR + '/index.html',
dest: 'www/'
},
scripts: {
src: 'src/cordova/**/*.js',
dest: 'www/cordova/'
}
};
// Clean the www directory
function clean() {
return del([
'www',
'platforms/android/assets/www'
]);
}
// Copy unmodified assets
function copy() {
return gulp.src(paths.assets.src)
.pipe(gulp.dest(paths.assets.dest));
}
// Add required tags to index.html
function index() {
return gulp.src(paths.index.src)
.pipe(dom(function() {
// inject CSP meta tag
var meta = this.createElement('meta');
meta.setAttribute('http-equiv', 'Content-Security-Policy');
meta.setAttribute('content', 'default-src * \'self\' \'unsafe-inline\' \'unsafe-eval\' blob: data: gap: file: filesystem: ws: wss:;');
this.head.appendChild(meta);
// inject appMode script
var appMode = this.createElement('script');
appMode.text = 'window.appMode=\'android\';';
this.body.appendChild(appMode);
// inject cordova.js
var cordova = this.createElement('script');
cordova.setAttribute('src', 'cordova.js');
cordova.setAttribute('defer', '');
this.body.appendChild(cordova);
// inject apploader.js
var apploader = this.createElement('script');
apploader.setAttribute('src', 'scripts/apploader.js');
apploader.setAttribute('defer', '');
this.body.appendChild(apploader);
return this;
}))
.pipe(gulp.dest(paths.index.dest))
}
function scripts() {
return gulp.src(paths.scripts.src)
.pipe(gulp.dest(paths.scripts.dest));
}
exports.clean = clean;
exports.copy = copy;
exports.index = index;
exports.scripts = scripts;
exports.default = gulp.series(clean, gulp.parallel(copy, index, scripts));