docs-nuxt-configuring-integration.md
8.2.0
Hooks of the build lifecycle.
beforeBuildServiceWorker(options) — Allows you to run some logic before the service worker is built.closeBundleOrder — Adjusts the application order of @serwist/vite’s closeBundle hook.configureOptions(viteOptions, options) — Allows you to configure the options of Serwist and Vite. Useful when there is a dependency between the two.vite.config.ts
export default defineConfig({
plugins: [
// Other plugins...
serwist({
swSrc: "src/sw.ts",
swDest: "sw.js",
injectionPoint: "self.__SW_MANIFEST",
rollupFormat: "iife",
integration: {
beforeBuildServiceWorker(options) {
console.log(`Building service worker with options:`, options);
},
closeBundleOrder: "pre",
configureOptions(viteConfig, options) {
const clientOutDir = path.resolve(viteConfig.root, viteConfig.build.outDir);
options.globDirectory = clientOutDir;
},
},
}),
],
});