diff --git a/packages/@vuepress/plugin-pwa/index.js b/packages/@vuepress/plugin-pwa/index.js index 748f1752c0..0bbf49e393 100644 --- a/packages/@vuepress/plugin-pwa/index.js +++ b/packages/@vuepress/plugin-pwa/index.js @@ -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, diff --git a/packages/docs/docs/plugin/official/plugin-pwa.md b/packages/docs/docs/plugin/official/plugin-pwa.md index ecee4ca1ce..0e532c11d4 100644 --- a/packages/docs/docs/plugin/official/plugin-pwa.md +++ b/packages/docs/docs/plugin/official/plugin-pwa.md @@ -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` diff --git a/packages/docs/docs/zh/plugin/official/plugin-pwa.md b/packages/docs/docs/zh/plugin/official/plugin-pwa.md index 14b514d557..6823f641f0 100644 --- a/packages/docs/docs/zh/plugin/official/plugin-pwa.md +++ b/packages/docs/docs/zh/plugin/official/plugin-pwa.md @@ -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`