@vite-pwa/nuxt 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.d.mts CHANGED
@@ -39,10 +39,10 @@ interface ModuleOptions extends PwaModuleOptions {
39
39
  }
40
40
  declare module '@nuxt/schema' {
41
41
  interface NuxtConfig {
42
- ['vuetify']?: Partial<ModuleOptions>;
42
+ ['pwa']?: Partial<ModuleOptions>;
43
43
  }
44
44
  interface NuxtOptions {
45
- ['vuetify']?: ModuleOptions;
45
+ ['pwa']?: ModuleOptions;
46
46
  }
47
47
  }
48
48
 
package/dist/module.d.ts CHANGED
@@ -39,10 +39,10 @@ interface ModuleOptions extends PwaModuleOptions {
39
39
  }
40
40
  declare module '@nuxt/schema' {
41
41
  interface NuxtConfig {
42
- ['vuetify']?: Partial<ModuleOptions>;
42
+ ['pwa']?: Partial<ModuleOptions>;
43
43
  }
44
44
  interface NuxtOptions {
45
- ['vuetify']?: ModuleOptions;
45
+ ['pwa']?: ModuleOptions;
46
46
  }
47
47
  }
48
48
 
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.6.5",
6
6
  "bridge": false
7
7
  },
8
- "version": "0.3.0"
8
+ "version": "0.3.2"
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { join } from 'node:path';
2
2
  import { writeFile, mkdir } from 'node:fs/promises';
3
- import { defineNuxtModule, createResolver, addPlugin, addComponent, extendWebpackConfig, getNuxtVersion } from '@nuxt/kit';
3
+ import { defineNuxtModule, createResolver, getNuxtVersion, addPlugin, addComponent, extendWebpackConfig } from '@nuxt/kit';
4
4
  import { VitePWA } from 'vite-plugin-pwa';
5
5
  import { resolve } from 'pathe';
6
6
 
7
- const version = "0.3.0";
7
+ const version = "0.3.2";
8
8
 
9
- function configurePWAOptions(options, nuxt, nitroConfig) {
9
+ function configurePWAOptions(nuxt3_8, options, nuxt, nitroConfig) {
10
10
  if (!options.outDir) {
11
11
  const publicDir = nitroConfig.output?.publicDir ?? nuxt.options.nitro?.output?.publicDir;
12
12
  options.outDir = publicDir ? resolve(publicDir) : resolve(nuxt.options.buildDir, "../.output/public");
@@ -32,10 +32,25 @@ function configurePWAOptions(options, nuxt, nitroConfig) {
32
32
  options.workbox.navigateFallback = nuxt.options.app.baseURL ?? "/";
33
33
  config = options.workbox;
34
34
  }
35
+ if (nuxt.options.experimental.payloadExtraction) {
36
+ config.globPatterns = config.globPatterns ?? [];
37
+ config.globPatterns.push("**/_payload.json");
38
+ }
39
+ let appManifestFolder;
40
+ if (nuxt3_8 && nuxt.options.experimental.appManifest) {
41
+ config.globPatterns = config.globPatterns ?? [];
42
+ appManifestFolder = nuxt.options.app.buildAssetsDir ?? "_nuxt/";
43
+ if (appManifestFolder[0] === "/")
44
+ appManifestFolder = appManifestFolder.slice(1);
45
+ if (appManifestFolder[appManifestFolder.length - 1] !== "/")
46
+ appManifestFolder += "/";
47
+ appManifestFolder += "builds/";
48
+ config.globPatterns.push(`${appManifestFolder}**/*.json`);
49
+ }
35
50
  if (!nuxt.options.dev && !config.manifestTransforms)
36
- config.manifestTransforms = [createManifestTransform(nuxt.options.app.baseURL ?? "/")];
51
+ config.manifestTransforms = [createManifestTransform(nuxt.options.app.baseURL ?? "/", appManifestFolder)];
37
52
  }
38
- function createManifestTransform(base) {
53
+ function createManifestTransform(base, appManifestFolder) {
39
54
  return async (entries) => {
40
55
  entries.filter((e) => e && e.url.endsWith(".html")).forEach((e) => {
41
56
  const url = e.url.startsWith("/") ? e.url.slice(1) : e.url;
@@ -47,6 +62,12 @@ function createManifestTransform(base) {
47
62
  e.url = parts.length > 1 ? parts.slice(0, parts.length - 1).join("/") : parts[0];
48
63
  }
49
64
  });
65
+ if (appManifestFolder) {
66
+ const regExp = /(\/)?[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\.json$/i;
67
+ entries.filter((e) => e && e.url.startsWith(appManifestFolder) && regExp.test(e.url)).forEach((e) => {
68
+ e.revision = null;
69
+ });
70
+ }
50
71
  return { manifest: entries, warnings: [] };
51
72
  };
52
73
  }
@@ -87,6 +108,8 @@ const module = defineNuxtModule({
87
108
  }),
88
109
  async setup(options, nuxt) {
89
110
  const resolver = createResolver(import.meta.url);
111
+ const nuxtVersion = getNuxtVersion(nuxt).split(".").map((v) => Number.parseInt(v));
112
+ const nuxt3_8 = nuxtVersion.length > 1 && (nuxtVersion[0] > 3 || nuxtVersion[0] === 3 && nuxtVersion[1] >= 8);
90
113
  let vitePwaClientPlugin;
91
114
  const resolveVitePluginPWAAPI = () => {
92
115
  return vitePwaClientPlugin?.api;
@@ -130,7 +153,7 @@ const module = defineNuxtModule({
130
153
  maxAge: 0
131
154
  });
132
155
  nuxt.hook("nitro:init", (nitro) => {
133
- configurePWAOptions(options, nuxt, nitro.options);
156
+ configurePWAOptions(nuxt3_8, options, nuxt, nitro.options);
134
157
  });
135
158
  nuxt.hook("vite:extend", ({ config }) => {
136
159
  const plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vite-plugin-pwa");
@@ -237,8 +260,6 @@ export const periodicSyncForUpdates = ${typeof client.periodicSyncForUpdates ===
237
260
  }
238
261
  });
239
262
  }
240
- const nuxtVersion = getNuxtVersion(nuxt).split(".").map((v) => Number.parseInt(v));
241
- const nuxt3_8 = nuxtVersion.length > 1 && (nuxtVersion[0] > 3 || nuxtVersion[0] === 3 && nuxtVersion[1] >= 8);
242
263
  if (nuxt3_8) {
243
264
  nuxt.hook("nitro:build:public-assets", async () => {
244
265
  await regeneratePWA(
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@vite-pwa/nuxt",
3
3
  "type": "module",
4
- "version": "0.3.0",
5
- "packageManager": "pnpm@8.10.5",
4
+ "version": "0.3.2",
5
+ "packageManager": "pnpm@8.11.0",
6
6
  "description": "Zero-config PWA for Nuxt 3",
7
7
  "author": "antfu <anthonyfu117@hotmail.com>",
8
8
  "license": "MIT",
@@ -66,7 +66,7 @@
66
66
  "@antfu/eslint-config": "^0.43.1",
67
67
  "@antfu/ni": "^0.21.10",
68
68
  "@nuxt/module-builder": "^0.5.4",
69
- "@nuxt/schema": "^3.8.1",
69
+ "@nuxt/schema": "^3.8.2",
70
70
  "@nuxt/test-utils": "^3.8.1",
71
71
  "@playwright/test": "^1.37.1",
72
72
  "@types/node": "^18",