Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/@vue/cli-plugin-pwa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ file, or the `"vue"` field in `package.json`.
- Default: `'default'`

- **pwa.assetsVersion**

- Default: `''`

This option is used if you need to add a version to your icons and manifest, against browser’s cache. This will append `?v=<pwa.assetsVersion>` to the URLs of the icons and manifest.
Expand All @@ -65,6 +65,19 @@ file, or the `"vue"` field in `package.json`.

The path of app’s manifest.

- **pwa.manifestOptions**

- Default: `{}`

The object will be used to generate the `manifest.json`

If the following attributes are not defined in the object, the options of `pwa` or default options will be used instead.
- name: `pwa.name`
- short_name: `pwa.name`
- start_url: `'.'`
- display: `'standalone'`
- theme_color: `pwa.themeColor`

- **pwa.iconPaths**

- Defaults:
Expand Down

This file was deleted.

45 changes: 44 additions & 1 deletion packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,26 @@ const defaults = {
appleMobileWebAppCapable: 'no',
appleMobileWebAppStatusBarStyle: 'default',
assetsVersion: '',
manifestPath: 'manifest.json'
manifestPath: 'manifest.json',
manifestOptions: {}
}

const defaultManifest = {
icons: [
{
"src": "./img/icons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "./img/icons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
start_url: '.',
display: 'standalone',
background_color: "#000000"
}

const defaultIconPaths = {
Expand Down Expand Up @@ -109,6 +128,30 @@ module.exports = class HtmlPwaPlugin {

cb(null, data)
})


})

compiler.hooks.emit.tapAsync(ID, (data, cb) => {
const {
name,
themeColor,
manifestPath,
manifestOptions
} = this.options
const publicOptions = {
name,
short_name: name,
theme_color: themeColor
}
const outputManifest = JSON.stringify(
Object.assign(publicOptions, defaultManifest, manifestOptions)
)
data.assets[manifestPath] = {
source: () => outputManifest,
size: () => outputManifest.length
}
cb(null, data)
})
}
}
Expand Down