Files
vue-cli/packages/@vue/cli-plugin-pwa
Jinesh Shah 36f954bfc9 feat(pwa): Make injected meta tags configurable and change defaults (#961)
This change proposes 2 things:

1. Make apple-mobile-web-app-capable and apple-mobile-web-app-status-bar-style configurable
2. Change the defaults to "no" and "default", respectively
2018-04-25 15:25:20 -04:00
..
2018-02-22 11:37:22 +09:00
2018-01-05 09:20:20 -05:00
2018-04-25 10:58:49 -04:00

@vue/cli-plugin-pwa

pwa plugin for vue-cli

Configuration

Configuration is handled via the pwa property of either the vue.config.js file, or the "vue" field in package.json.

  • pwa.workboxPluginMode

    This allows you to the choose between the two modes supported by the underlying workbox-webpack-plugin.

    • 'GenerateSW' (default), will lead to a new service worker file being created each time you rebuild your web app.

    • 'InjectManifest' allows you to start with an existing service worker file, and creates a copy of that file with a "precache manifest" injected into it.

    The "Which Plugin to Use?" guide can help you choose between the two modes.

  • pwa.workboxOptions

    These options are passed on through to the underlying workbox-webpack-plugin.

    For more information on what values are supported, please see the guide for GenerateSW or for InjectManifest.

Example Configuration

// Inside vue.config.js
module.exports = {
  // ...other vue-cli plugin options...
  pwa: {
    name: 'My App', // used for apple-mobile-web-app-title
    themeColor: '#4DBA87',
    msTileColor: '#000000',
    workboxPluginMode: 'InjectManifest',
    workboxOptions: {
      // swSrc is required in InjectManifest mode.
      swSrc: 'dev/sw.js',
      // ...other Workbox options...
    }
  }
}

Installing in an Already Created Project

npm install -D @vue/cli-plugin-pwa
vue invoke pwa

Injected webpack-chain Rules

  • config.plugin('workbox')