Skip to main content

plugins

First added

8.2.0

About

Rollup/Vite plugins used to build the service worker.

Usage

import replace from "@rollup/plugin-replace";

export default defineConfig({
  plugins: [
    // Other plugins...
    serwist({
      swSrc: "src/sw.ts",
      swDest: "sw.js",
      globDirectory: "dist",
      injectionPoint: "self.__SW_MANIFEST",
      rollupFormat: "iife",
      plugins: [
        replace({
          __BUILD_DATE__: () => JSON.stringify(new Date()),
          __BUILD_VERSION__: 15,
        }),
      ],
    }),
  ],
});

More resources

Here is a list of resources you can read to learn more about plugins: