UNPKG

831 BJavaScriptView Raw
1const Asset = require('../Asset');
2
3class WebManifestAsset extends Asset {
4 constructor(name, options) {
5 super(name, options);
6 this.type = 'webmanifest';
7 }
8
9 parse(content) {
10 return JSON.parse(content);
11 }
12
13 collectDependencies() {
14 if (Array.isArray(this.ast.icons)) {
15 for (let icon of this.ast.icons) {
16 icon.src = this.addURLDependency(icon.src);
17 }
18 }
19
20 if (Array.isArray(this.ast.screenshots)) {
21 for (let shot of this.ast.screenshots) {
22 shot.src = this.addURLDependency(shot.src);
23 }
24 }
25
26 if (this.ast.serviceworker && this.ast.serviceworker.src) {
27 this.ast.serviceworker.src = this.addURLDependency(
28 this.ast.serviceworker.src
29 );
30 }
31 }
32
33 generate() {
34 return JSON.stringify(this.ast);
35 }
36}
37
38module.exports = WebManifestAsset;