@vite-pwa/nuxt 0.3.2 → 0.3.4

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.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.6.5",
6
6
  "bridge": false
7
7
  },
8
- "version": "0.3.2"
8
+ "version": "0.3.4"
9
9
  }
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import { defineNuxtModule, createResolver, getNuxtVersion, addPlugin, addCompone
4
4
  import { VitePWA } from 'vite-plugin-pwa';
5
5
  import { resolve } from 'pathe';
6
6
 
7
- const version = "0.3.2";
7
+ const version = "0.3.4";
8
8
 
9
9
  function configurePWAOptions(nuxt3_8, options, nuxt, nitroConfig) {
10
10
  if (!options.outDir) {
@@ -32,19 +32,24 @@ function configurePWAOptions(nuxt3_8, options, nuxt, nitroConfig) {
32
32
  options.workbox.navigateFallback = nuxt.options.app.baseURL ?? "/";
33
33
  config = options.workbox;
34
34
  }
35
+ let buildAssetsDir = nuxt.options.app.buildAssetsDir ?? "_nuxt/";
36
+ if (buildAssetsDir[0] === "/")
37
+ buildAssetsDir = buildAssetsDir.slice(1);
38
+ if (buildAssetsDir[buildAssetsDir.length - 1] !== "/")
39
+ buildAssetsDir += "/";
40
+ if (!("dontCacheBustURLsMatching" in config))
41
+ config.dontCacheBustURLsMatching = new RegExp(buildAssetsDir);
35
42
  if (nuxt.options.experimental.payloadExtraction) {
36
- config.globPatterns = config.globPatterns ?? [];
37
- config.globPatterns.push("**/_payload.json");
43
+ const enableGlobPatterns = nuxt.options._generate || (!!nitroConfig.prerender?.routes?.length || Object.values(nitroConfig.routeRules ?? {}).some((r) => r.prerender));
44
+ if (enableGlobPatterns) {
45
+ config.globPatterns = config.globPatterns ?? [];
46
+ config.globPatterns.push("**/_payload.json");
47
+ }
38
48
  }
39
49
  let appManifestFolder;
40
50
  if (nuxt3_8 && nuxt.options.experimental.appManifest) {
41
51
  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/";
52
+ appManifestFolder = `${buildAssetsDir}builds/`;
48
53
  config.globPatterns.push(`${appManifestFolder}**/*.json`);
49
54
  }
50
55
  if (!nuxt.options.dev && !config.manifestTransforms)
@@ -123,11 +128,6 @@ const module = defineNuxtModule({
123
128
  src: resolver.resolve(runtimeDir, "plugins/pwa.client"),
124
129
  mode: "client"
125
130
  });
126
- } else {
127
- addPlugin({
128
- src: resolver.resolve(runtimeDir, "plugins/pwa.client.stub"),
129
- mode: "client"
130
- });
131
131
  }
132
132
  await Promise.all([
133
133
  addComponent({
@@ -140,8 +140,7 @@ const module = defineNuxtModule({
140
140
  })
141
141
  ]);
142
142
  nuxt.hook("prepare:types", ({ references }) => {
143
- const types = resolver.resolve(runtimeDir, "plugins/types");
144
- references.push({ path: resolver.resolve(nuxt.options.buildDir, types) });
143
+ references.push({ path: resolver.resolve(runtimeDir, "plugins/types") });
145
144
  references.push({ types: "@vite-pwa/nuxt/configuration" });
146
145
  references.push({ types: "vite-plugin-pwa/vue" });
147
146
  references.push({ types: "vite-plugin-pwa/info" });
package/dist/types.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import type { ModuleOptions } from './module'
2
+ import type { ModuleOptions } from './module.js'
3
3
 
4
4
 
5
5
  declare module '@nuxt/schema' {
@@ -13,4 +13,4 @@ declare module 'nuxt/schema' {
13
13
  }
14
14
 
15
15
 
16
- export type { ClientOptions, ModuleOptions, PwaModuleOptions, default } from './module'
16
+ export type { ClientOptions, ModuleOptions, PwaModuleOptions, default } from './module.js'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vite-pwa/nuxt",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "packageManager": "pnpm@8.11.0",
6
6
  "description": "Zero-config PWA for Nuxt 3",
7
7
  "author": "antfu <anthonyfu117@hotmail.com>",
@@ -30,20 +30,20 @@
30
30
  },
31
31
  "./*": "./*"
32
32
  },
33
- "main": "./dist/module.cjs",
33
+ "main": "./dist/module.mjs",
34
34
  "types": "./dist/types.d.ts",
35
35
  "files": [
36
36
  "dist",
37
37
  "*.d.ts"
38
38
  ],
39
39
  "scripts": {
40
- "prepack": "nuxt-module-build prepare && nuxt-module-build build",
40
+ "prepack": "nuxt-module-build prepare && nuxt-module-build build && jiti scripts/postbuild.ts",
41
41
  "dev": "nuxi dev playground",
42
42
  "dev:generate": "nuxi generate playground",
43
43
  "dev:generate:netlify": "NITRO_PRESET=netlify nuxi generate playground",
44
44
  "dev:generate:vercel": "NITRO_PRESET=vercel nuxi generate playground",
45
45
  "dev:build": "nuxi build playground",
46
- "dev:prepare": "nuxt-module-build --stub && nuxt-module-build prepare && nuxi prepare playground",
46
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
47
47
  "dev:preview:build": "nr dev:build && node playground/.output/server/index.mjs",
48
48
  "dev:preview:generate": "nr dev:generate && serve playground/dist",
49
49
  "release": "bumpp && npm publish",
@@ -93,5 +93,8 @@
93
93
  "vite",
94
94
  "vite-plugin-pwa"
95
95
  ]
96
+ },
97
+ "stackblitz": {
98
+ "startCommand": "nr prepack && nr dev:prepare && nr dev"
96
99
  }
97
100
  }
@@ -1,7 +0,0 @@
1
- import type { UnwrapNestedRefs } from 'vue';
2
- import type { PwaInjection } from './types';
3
- import type { Plugin } from '#app';
4
- declare const plugin: Plugin<{
5
- pwa?: UnwrapNestedRefs<PwaInjection>;
6
- }>;
7
- export default plugin;
@@ -1,9 +0,0 @@
1
- import { defineNuxtPlugin } from "#imports";
2
- const plugin = defineNuxtPlugin(() => {
3
- return {
4
- provide: {
5
- pwa: void 0
6
- }
7
- };
8
- });
9
- export default plugin;