feat($plugin-pwa): allow using local workbox files (close: #539)

This commit is contained in:
ULIVZ
2019-04-07 01:33:10 +08:00
parent 9420ca9233
commit 46406148f6
3 changed files with 18 additions and 1 deletions
+2 -1
View File
@@ -40,7 +40,8 @@ module.exports = (options, context) => ({
await wbb.generateSW({
swDest: swFilePath,
globDirectory: outDir,
globPatterns: ['**\/*.{js,css,html,png,jpg,jpeg,gif,svg,woff,woff2,eot,ttf,otf}']
globPatterns: ['**\/*.{js,css,html,png,jpg,jpeg,gif,svg,woff,woff2,eot,ttf,otf}'],
...(options.generateSWConfig || {})
})
await fs.writeFile(
swFilePath,
@@ -45,6 +45,14 @@ The `serviceWorker` option only handles the service worker. To make your site fu
Also, only enable this if you are able to deploy your site with SSL, since service worker can only be registered under HTTPs URLs.
:::
### generateSWConfig
- Type: `object`
- Default: `{}`
[generateSW config](https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config) of workbox-build.
### updatePopup
- Type: `boolean|object`
@@ -44,6 +44,14 @@ module.exports = {
此外,只有您能够使用 SSL 部署您的站点时才能启用此功能,因为 service worker 只能在 HTTPs 的 URL 下注册。
:::
### generateSWConfig
- 类型: `object`
- 默认值: `{}`
workbox-build 的 [generateSW config](https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config)。
### updatePopup
- 类型: `boolean|popupConfig`