File tree Expand file tree Collapse file tree 4 files changed +37
-7
lines changed Expand file tree Collapse file tree 4 files changed +37
-7
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,14 @@ const sw = process.env.SW === 'true'
5
5
export default defineNuxtConfig ( {
6
6
/* ssr: false, */
7
7
// typescript,
8
- modules : [ '@vite-pwa/nuxt' ] ,
8
+ modules : [
9
+ '@vite-pwa/nuxt' ,
10
+ ( _ , nuxt ) => {
11
+ nuxt . hook ( 'pwa:beforeBuildServiceWorker' , ( options ) => {
12
+ console . log ( 'pwa:beforeBuildServiceWorker: ' , options . base )
13
+ } )
14
+ } ,
15
+ ] ,
9
16
future : {
10
17
typescriptBundlerResolution : true ,
11
18
} ,
@@ -20,7 +27,7 @@ export default defineNuxtConfig({
20
27
} ,
21
28
} ,
22
29
prerender : {
23
- routes : [ '/' , '/about' ] ,
30
+ routes : [ '/' /* , '/about' */ ] ,
24
31
} ,
25
32
} ,
26
33
imports : {
@@ -73,6 +80,9 @@ export default defineNuxtConfig({
73
80
// if enabling periodic sync for update use 1 hour or so (periodicSyncForUpdates: 3600)
74
81
periodicSyncForUpdates : 20 ,
75
82
} ,
83
+ experimental : {
84
+ includeAllowlist : true ,
85
+ } ,
76
86
devOptions : {
77
87
enabled : true ,
78
88
suppressWarnings : true ,
Original file line number Diff line number Diff line change 1
1
import type { HookResult } from '@nuxt/schema'
2
- import type { PwaModuleOptions } from './types'
2
+ import type { PwaModuleOptions , ResolvedVitePWAOptions } from './types'
3
3
import { defineNuxtModule } from '@nuxt/kit'
4
4
import { version } from '../package.json'
5
5
import { doSetup } from './utils/module'
@@ -8,6 +8,10 @@ export * from './types'
8
8
9
9
export interface ModuleOptions extends PwaModuleOptions { }
10
10
11
+ export interface ModuleHooks {
12
+ 'pwa:beforeBuildServiceWorker' : ( options : ResolvedVitePWAOptions ) => HookResult
13
+ }
14
+
11
15
export interface ModuleRuntimeHooks {
12
16
/**
13
17
* Emitted when the service worker is registered
Original file line number Diff line number Diff line change 1
1
import type { VitePWAOptions } from 'vite-plugin-pwa'
2
2
3
+ export type { ResolvedVitePWAOptions } from 'vite-plugin-pwa'
4
+
3
5
export interface ClientOptions {
4
6
/**
5
7
* Exposes the plugin: defaults to true.
@@ -52,11 +54,12 @@ export interface PwaModuleOptions extends Partial<VitePWAOptions> {
52
54
* const newUrl = new URL(url.href)
53
55
* newUrl.search = ''
54
56
* urls.push(newUrl)
55
- * }
56
- * return urls
57
- * }
58
- * }
57
+ * }
58
+ * return urls
59
+ * }
60
+ * }
59
61
* )
62
+ * ```
60
63
*/
61
64
enableWorkboxPayloadQueryParams ?: true
62
65
}
Original file line number Diff line number Diff line change @@ -112,6 +112,19 @@ export function configurePWAOptions(
112
112
outDir : options . outDir ,
113
113
}
114
114
}
115
+
116
+ const integration = options . integration ?? { }
117
+ const {
118
+ beforeBuildServiceWorker : original ,
119
+ ...rest
120
+ } = integration
121
+ options . integration = {
122
+ ...rest ,
123
+ async beforeBuildServiceWorker ( resolvedPwaOptions ) {
124
+ await original ?.( resolvedPwaOptions )
125
+ await nuxt . callHook ( 'pwa:beforeBuildServiceWorker' , resolvedPwaOptions )
126
+ } ,
127
+ }
115
128
}
116
129
117
130
function createManifestTransform (
You can’t perform that action at this time.
0 commit comments