0.1.3 • Published 3 years ago

vue-cli-plugin-bundle-service-worker v0.1.3

Weekly downloads
333
License
MIT
Repository
github
Last release
3 years ago

vue-cli-plugin-bundle-service-worker

Builds your service worker with webpack. Primary use case is if your service worker imports/requires modules other than the workbox libs.

Requires the @vue/pwa plugin to be installed and configured using workboxPluginMode === 'InjectManifest'.

Installation

npx @vue/cli add bundle-service-worker
// vue.config.js

module.exports = {

// You must configure the @vue/pwa plugin.

    pwa: {
        workboxPluginMode: "InjectManifest",
        workboxOptions: {
            swSrc: "src/service-worker.js"
        }
    },

    pluginOptions: {

// However, this configuration is optional.

        "vue-cli-plugin-bundle-service-worker": {

// You can further configure Webpack by merging and/or chaining.

            configureWebpack: {
                plugins: [
                    new MyAwesomeWebpackPlugin()
                ]
            },
            chainWebpack(config) {
                config.plugin("define").tap(function ([definitions]) {

// Environment variables recognised by Vue CLI will automatically be included
// (e.g. NODE_ENV, BASE_URL and VUE_APP_*), but all others must be explicitly
// set here.

                    definitions["process.env.MY_VAR"] = JSON.stringify(
                        process.env.MY_VAR
                    );
                    return [definitions];
                });
            }
        }
    }
};

In this case, src/service-worker.js will be built by webpack, then the manifest & workbox libs will be injected.

Building manually

For debugging purposes, you can build your service worker manually. Note that the built service worker will not have it's precache manifest injected, or the workbox libs included - this takes place only when you call vue-cli-service build.

npx vue-cli-service build:sw
0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

6 years ago

0.0.1

6 years ago