Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vite-pwa/vite-plugin-pwa
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.21.1
Choose a base ref
...
head repository: vite-pwa/vite-plugin-pwa
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.21.2
Choose a head ref
  • 6 commits
  • 83 files changed
  • 5 contributors

Commits on Mar 21, 2025

  1. chore: update ReloadPrompt.tsx in react router example (#825)

    Changed className from "ReloadPrompt-message" to "ReloadPrompt-toast-message" to match the css.
    Supalien authored Mar 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2949c3a View commit details
  2. fix(manifest): default manifest theme_color and description not b…

    …eing applied (#839)
    
    * fix(manifest): default description need to come from package
    
    * fix(manifest): same for theme_color
    alexandre-hallaine authored Mar 21, 2025
    Copy the full SHA
    53568d0 View commit details
  3. Copy the full SHA
    fc65109 View commit details
  4. chore: remove redundant async in vue examples (#826)

    * docs: remove redundant async
    
    * chore: revert docs changes
    
    ---------
    
    Co-authored-by: userquin <userquin@gmail.com>
    huangmingfu and userquin authored Mar 21, 2025
    Copy the full SHA
    6206afb View commit details
  5. chore: remove usage of deprecated reloadPage param in examples (#842)

    * chore: remove deprecations
    
    ---------
    
    Co-authored-by: piotr-cz <hello@piotr.cz>
    userquin and piotr-cz authored Mar 21, 2025
    Copy the full SHA
    2445e44 View commit details
  6. chore: release v0.21.2

    userquin committed Mar 21, 2025
    Copy the full SHA
    11923f3 View commit details
Showing with 2,028 additions and 981 deletions.
  1. +5 −0 .github/workflows/cr.yml
  2. +1 −1 .github/workflows/release.yml
  3. +1 −1 CONTRIBUTING.md
  4. +4 −6 README.md
  5. +2 −0 eslint.config.js
  6. +1 −1 examples/assets-generator/src/pwa.ts
  7. +1 −1 examples/assets-generator/vite.config.ts
  8. +12 −12 examples/preact-router/src/ReloadPrompt.tsx
  9. +2 −2 examples/preact-router/src/app.tsx
  10. +1 −1 examples/preact-router/src/claims-sw.ts
  11. +1 −1 examples/preact-router/src/pages/Home.tsx
  12. +3 −3 examples/preact-router/test/build.test.ts
  13. +3 −3 examples/preact-router/vite.config.ts
  14. +12 −12 examples/react-router/src/ReloadPrompt.tsx
  15. +1 −1 examples/react-router/src/claims-sw.ts
  16. +3 −3 examples/react-router/src/main.tsx
  17. +3 −3 examples/react-router/test/build.test.ts
  18. +3 −3 examples/react-router/vite.config.ts
  19. +2 −2 examples/solid-router/src/ReloadPrompt.tsx
  20. +1 −1 examples/solid-router/src/app.tsx
  21. +1 −1 examples/solid-router/src/claims-sw.ts
  22. +1 −1 examples/solid-router/src/index.tsx
  23. +1 −1 examples/solid-router/src/pages/home.tsx
  24. +2 −2 examples/solid-router/src/routes.ts
  25. +3 −3 examples/solid-router/test/build.test.ts
  26. +3 −3 examples/solid-router/vite.config.ts
  27. +1 −1 examples/svelte-routify/src/claims-sw.ts
  28. +1 −1 examples/svelte-routify/src/lib/ReloadPrompt.svelte
  29. +2 −2 examples/svelte-routify/test/build.test.ts
  30. +2 −2 examples/svelte-routify/vite.config.js
  31. +2 −2 examples/sveltekit-pwa/pwa.js
  32. +1 −1 examples/sveltekit-pwa/src/claims-sw.ts
  33. +1 −1 examples/sveltekit-pwa/src/lib/components/ReloadPrompt.svelte
  34. +1 −1 examples/sveltekit-pwa/svelte.config.js
  35. +1 −1 examples/vanilla-js-custom-sw/service-worker/sw.js
  36. +1 −0 examples/vanilla-js-custom-sw/src/main.js
  37. +1 −1 examples/vanilla-ts-no-ip/client-test/sw.spec.ts
  38. +3 −3 examples/vanilla-ts-no-ip/src/custom-sw.ts
  39. +3 −3 examples/vanilla-ts-no-ip/test/build.test.ts
  40. +1 −1 examples/vue-basic-cdn/src/ReloadPrompt.vue
  41. +2 −2 examples/vue-basic-cdn/vite.config.ts
  42. +1 −1 examples/vue-router/src/App.vue
  43. +2 −2 examples/vue-router/src/ReloadPrompt.vue
  44. +2 −2 examples/vue-router/src/claims-sw.ts
  45. +2 −2 examples/vue-router/src/pages/hi/[name].vue
  46. +1 −1 examples/vue-router/src/pages/home.vue
  47. +1 −1 examples/vue-router/src/prompt-sw.ts
  48. +3 −3 examples/vue-router/test/build.test.ts
  49. +4 −4 examples/vue-router/vite.config.ts
  50. +6 −6 package.json
  51. +1,807 −768 pnpm-lock.yaml
  52. +1 −1 preact.d.ts
  53. +1 −1 react.d.ts
  54. +1 −1 scripts/run-examples.ts
  55. +1 −1 solid.d.ts
  56. +5 −5 src/api.ts
  57. +5 −5 src/assets.ts
  58. +2 −1 src/cache.ts
  59. +1 −1 src/client/dev/preact.ts
  60. +1 −1 src/client/dev/react.ts
  61. +1 −1 src/client/dev/solid.ts
  62. +1 −1 src/client/dev/svelte.ts
  63. +1 −1 src/client/dev/vue.ts
  64. +3 −3 src/context.ts
  65. +1 −1 src/html.ts
  66. +5 −5 src/index.ts
  67. +6 −6 src/log.ts
  68. +6 −6 src/modules.ts
  69. +7 −5 src/options.ts
  70. +2 −2 src/plugins/build.ts
  71. +11 −11 src/plugins/dev.ts
  72. +1 −1 src/plugins/info.ts
  73. +13 −14 src/plugins/main.ts
  74. +1 −1 src/plugins/pwa-assets.ts
  75. +1 −1 src/pwa-assets/build.ts
  76. +5 −5 src/pwa-assets/config.ts
  77. +1 −1 src/pwa-assets/generator.ts
  78. +3 −3 src/pwa-assets/html.ts
  79. +1 −1 src/pwa-assets/manifest.ts
  80. +10 −10 src/types.ts
  81. +2 −2 src/vite-build.ts
  82. +1 −1 svelte.d.ts
  83. +2 −2 vue.d.ts
5 changes: 5 additions & 0 deletions .github/workflows/cr.yml
Original file line number Diff line number Diff line change
@@ -22,6 +22,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4.0.0
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- run: pnpm install
- run: pnpm build
- run: pnpx pkg-pr-new publish --compact --no-template --pnpm
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20.17.0

- run: npx changelogithub
env:
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ The `vite-plugin-pwa` repo includes a set of examples where you can test the cha
- `pnpm run examples`: select `sveltekit` framework and default options on the cli (you can also test another options)
- `pnpm run examples`: select `solid` framework and default options on the cli (you can also test another options)

> The default options from the `cli` are just to check your changes are not breaking major ui/app frameworks build: `generateSW` strategy, `Prompt for update` behavior and `Enable periodic SW updates` to `no`.
> The default options from the `cli` are just to check your changes are not breaking major ui/app frameworks build: `generateSW` strategy, `Prompt for update` behavior and `Enable periodic SW updates` to `no`.
> If your changes are specific to some behavior, just use the corresponding option on the `cli`.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ Zero-config PWA Framework-agnostic Plugin for Vite
</a>
</p>


## 🚀 Features

- 📖 [**Documentation & guides**](https://vite-pwa-org.netlify.app/)
@@ -53,12 +52,12 @@ Zero-config PWA Framework-agnostic Plugin for Vite
> From v0.13, `vite-plugin-pwa` requires **Vite 3.1 or above**.
```bash
npm i vite-plugin-pwa -D
npm i vite-plugin-pwa -D

# yarn
# yarn
yarn add vite-plugin-pwa -D

# pnpm
# pnpm
pnpm add vite-plugin-pwa -D
```

@@ -77,7 +76,7 @@ export default {
}
```

Read the [📖 documentation](https://vite-pwa-org.netlify.app/guide/) for a complete guide on how to configure and use
Read the [📖 documentation](https://vite-pwa-org.netlify.app/guide/) for a complete guide on how to configure and use
this plugin.

Check out the client type declarations [client.d.ts](./client.d.ts) for built-in frameworks support.
@@ -89,7 +88,6 @@ Check out the type declaration [src/types.ts](./src/types.ts) and the following
- [Web app manifests](https://developer.mozilla.org/en-US/docs/Web/Manifest)
- [Workbox](https://developers.google.com/web/tools/workbox)


## 📄 License

[MIT](./LICENSE) License &copy; 2020-PRESENT [Anthony Fu](https://github.com/antfu)
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -3,8 +3,10 @@ import antfu from '@antfu/eslint-config'
export default await antfu(
{
ignores: [
'netlify.toml',
'**/build/**',
'**/dist/**',
'**/docs/**',
'**/dev-dist/**',
],
},
2 changes: 1 addition & 1 deletion examples/assets-generator/src/pwa.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pwaInfo } from 'virtual:pwa-info'
import { pwaAssetsHead } from 'virtual:pwa-assets/head'
import { pwaAssetsIcons } from 'virtual:pwa-assets/icons'
import { pwaInfo } from 'virtual:pwa-info'
import { registerSW } from 'virtual:pwa-register'

console.log(pwaInfo)
2 changes: 1 addition & 1 deletion examples/assets-generator/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import type { PWAAssetsOptions } from 'vite-plugin-pwa'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'

const pwaAssets: PWAAssetsOptions = process.env.INLINE_PWA_ASSETS
24 changes: 12 additions & 12 deletions examples/preact-router/src/ReloadPrompt.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './ReloadPrompt.css'
import { pwaInfo } from 'virtual:pwa-info'

import { useRegisterSW } from 'virtual:pwa-register/preact'
import { pwaInfo } from 'virtual:pwa-info'
import './ReloadPrompt.css'

console.log(pwaInfo)

@@ -43,17 +43,17 @@ function ReloadPrompt() {
return (
<div className="ReloadPrompt-container">
{ (offlineReady || needRefresh)
&& (
<div className="ReloadPrompt-toast">
<div className="ReloadPrompt-message">
{ offlineReady
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>}
&& (
<div className="ReloadPrompt-toast">
<div className="ReloadPrompt-message">
{ offlineReady
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>}
</div>
{ needRefresh && <button className="ReloadPrompt-toast-button" onClick={() => updateServiceWorker()}>Reload</button> }
<button className="ReloadPrompt-toast-button" onClick={() => close()}>Close</button>
</div>
{ needRefresh && <button className="ReloadPrompt-toast-button" onClick={() => updateServiceWorker(true)}>Reload</button> }
<button className="ReloadPrompt-toast-button" onClick={() => close()}>Close</button>
</div>
)}
)}
<div className="ReloadPrompt-date">{buildDate}</div>
</div>
)
4 changes: 2 additions & 2 deletions examples/preact-router/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Router } from 'preact-router'

import ReloadPrompt from './ReloadPrompt'
import Home from './pages/Home'
import About from './pages/About'
import Hi from './pages/hi/[name]'
import Home from './pages/Home'
import ReloadPrompt from './ReloadPrompt'

import './App.css'

2 changes: 1 addition & 1 deletion examples/preact-router/src/claims-sw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { clientsClaim } from 'workbox-core'
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { NavigationRoute, registerRoute } from 'workbox-routing'

declare let self: ServiceWorkerGlobalScope
2 changes: 1 addition & 1 deletion examples/preact-router/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'preact/hooks'
import { route } from 'preact-router'
import { useState } from 'preact/hooks'
import './Home.css'

function Home() {
6 changes: 3 additions & 3 deletions examples/preact-router/test/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync, readFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import process from 'node:process'
import { fileURLToPath } from 'node:url'

import { describe, expect, it } from 'vitest'

@@ -32,13 +32,13 @@ describe('preact: test-build', () => {
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
match = swContent.match(/self\['workbox:core:[0-9.]+'\]/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
6 changes: 3 additions & 3 deletions examples/preact-router/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa'
import process from 'node:process'
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
import { VitePWA } from 'vite-plugin-pwa'
import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa'
import replace from '@rollup/plugin-replace'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'

const pwaOptions: Partial<VitePWAOptions> = {
mode: 'development',
24 changes: 12 additions & 12 deletions examples/react-router/src/ReloadPrompt.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import './ReloadPrompt.css'
import { pwaInfo } from 'virtual:pwa-info'

import { useRegisterSW } from 'virtual:pwa-register/react'
import { pwaInfo } from 'virtual:pwa-info'
import './ReloadPrompt.css'

console.log(pwaInfo)

@@ -44,17 +44,17 @@ function ReloadPrompt() {
return (
<div className="ReloadPrompt-container">
{ (offlineReady || needRefresh)
&& (
<div className="ReloadPrompt-toast">
<div className="ReloadPrompt-message">
{ offlineReady
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>}
&& (
<div className="ReloadPrompt-toast">
<div className="ReloadPrompt-toast-message">
{ offlineReady
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>}
</div>
{ needRefresh && <button className="ReloadPrompt-toast-button" onClick={() => updateServiceWorker()}>Reload</button> }
<button className="ReloadPrompt-toast-button" onClick={() => close()}>Close</button>
</div>
{ needRefresh && <button className="ReloadPrompt-toast-button" onClick={() => updateServiceWorker(true)}>Reload</button> }
<button className="ReloadPrompt-toast-button" onClick={() => close()}>Close</button>
</div>
)}
)}
<div className="ReloadPrompt-date">{buildDate}</div>
</div>
)
2 changes: 1 addition & 1 deletion examples/react-router/src/claims-sw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { clientsClaim } from 'workbox-core'
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { NavigationRoute, registerRoute } from 'workbox-routing'

declare let self: ServiceWorkerGlobalScope
6 changes: 3 additions & 3 deletions examples/react-router/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'
import { BrowserRouter, Route, Routes } from 'react-router-dom'
import { createRoot } from 'react-dom/client'
import './index.css'
import { BrowserRouter, Route, Routes } from 'react-router-dom'
import App from './App'
import Home from './pages/Home'
import About from './pages/About'
import Hi from './pages/hi/[name]'
import Home from './pages/Home'
import './index.css'

createRoot(document.getElementById('app')!).render(
<BrowserRouter>
6 changes: 3 additions & 3 deletions examples/react-router/test/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync, readFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'

const _dirname = typeof __dirname !== 'undefined'
@@ -31,13 +31,13 @@ describe('react: test-build', () => {
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
match = swContent.match(/self\['workbox:core:[0-9.]+'\]/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
6 changes: 3 additions & 3 deletions examples/react-router/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa'
import process from 'node:process'
import { defineConfig } from 'vite'
import replace from '@rollup/plugin-replace'
import react from '@vitejs/plugin-react'
import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import replace from '@rollup/plugin-replace'

const pwaOptions: Partial<VitePWAOptions> = {
mode: 'development',
4 changes: 2 additions & 2 deletions examples/solid-router/src/ReloadPrompt.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Component } from 'solid-js'
import { Show } from 'solid-js'
import { useRegisterSW } from 'virtual:pwa-register/solid'
import { pwaInfo } from 'virtual:pwa-info'
import { useRegisterSW } from 'virtual:pwa-register/solid'
import styles from './ReloadPrompt.module.css'

console.log(pwaInfo)
@@ -51,7 +51,7 @@ const ReloadPrompt: Component = () => {
</Show>
</div>
<Show when={needRefresh()}>
<button class={styles.ToastButton} onClick={() => updateServiceWorker(true)}>Reload</button>
<button class={styles.ToastButton} onClick={() => updateServiceWorker()}>Reload</button>
</Show>
<button class={styles.ToastButton} onClick={() => close()}>Close</button>
</div>
2 changes: 1 addition & 1 deletion examples/solid-router/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Component } from 'solid-js'
import { useRoutes } from '@solidjs/router'
import { routes } from './routes'
import styles from './app.module.css'
import ReloadPrompt from './ReloadPrompt'
import { routes } from './routes'

const App: Component = () => {
// replaced dynamically
2 changes: 1 addition & 1 deletion examples/solid-router/src/claims-sw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { clientsClaim } from 'workbox-core'
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { NavigationRoute, registerRoute } from 'workbox-routing'

declare let self: ServiceWorkerGlobalScope
2 changes: 1 addition & 1 deletion examples/solid-router/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from 'solid-js/web'
import { Router } from '@solidjs/router'
import { render } from 'solid-js/web'
import App from './app'

render(
2 changes: 1 addition & 1 deletion examples/solid-router/src/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSignal } from 'solid-js'
import { useNavigate } from '@solidjs/router'
import { createSignal } from 'solid-js'
import styles from './home.module.css'

export default function Home() {
4 changes: 2 additions & 2 deletions examples/solid-router/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { lazy } from 'solid-js'
import type { RouteDefinition } from '@solidjs/router'
import { lazy } from 'solid-js'

import Home from './pages/home'
import HiData from './pages/hi/[name].data'
import Home from './pages/home'

export const routes: RouteDefinition[] = [
{
6 changes: 3 additions & 3 deletions examples/solid-router/test/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync, readFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'

const _dirname = typeof __dirname !== 'undefined'
@@ -31,13 +31,13 @@ describe('solid: test-build', () => {
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
match = swContent.match(/self\['workbox:core:[0-9.]+'\]/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
6 changes: 3 additions & 3 deletions examples/solid-router/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa'
import process from 'node:process'
import replace from '@rollup/plugin-replace'
import { defineConfig } from 'vite'
import solidPlugin from 'vite-plugin-solid'
import { VitePWA } from 'vite-plugin-pwa'
import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa'
import replace from '@rollup/plugin-replace'
import solidPlugin from 'vite-plugin-solid'

const pwaOptions: Partial<VitePWAOptions> = {
mode: 'development',
Loading