-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Add WebManifestAsset to handle W3C webmanifest (#691)
- Loading branch information
1 parent
29ac70b
commit 1d49e47
Showing
6 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const Asset = require('../Asset'); | ||
|
||
class WebManifestAsset extends Asset { | ||
constructor(name, pkg, options) { | ||
super(name, pkg, options); | ||
this.type = 'webmanifest'; | ||
} | ||
|
||
parse(content) { | ||
return JSON.parse(content); | ||
} | ||
|
||
collectDependencies() { | ||
if (Array.isArray(this.ast.icons)) { | ||
for (let icon of this.ast.icons) { | ||
icon.src = this.addURLDependency(icon.src); | ||
} | ||
} | ||
|
||
if (Array.isArray(this.ast.screenshots)) { | ||
for (let shot of this.ast.screenshots) { | ||
shot.src = this.addURLDependency(shot.src); | ||
} | ||
} | ||
|
||
if (this.ast.serviceworker && this.ast.serviceworker.src) { | ||
this.ast.serviceworker.src = this.addURLDependency( | ||
this.ast.serviceworker.src | ||
); | ||
} | ||
} | ||
|
||
generate() { | ||
return { | ||
webmanifest: JSON.stringify(this.ast) | ||
}; | ||
} | ||
} | ||
|
||
module.exports = WebManifestAsset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!doctype html> | ||
<html> | ||
<head><link rel="manifest" href="manifest.webmanifest"></head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "example", | ||
"icons": [ | ||
{ | ||
"src": "some.txt", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
} | ||
], | ||
"display": "standalone" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
working |