Skip to content

Commit b22c1f8

Browse files
brc-dduserquin
andauthored
fix: use module augmentation instead of extending config (vite-pwa#9)
* fix: use module augmentation instead of extending config * chore: updated pwa plugin and pnpm chore: add integration to types in pwa-simple * chore: updated pwa plugin (local copy of PR 378) Co-authored-by: userquin <userquin@gmail.com>
1 parent 087a253 commit b22c1f8

File tree

11 files changed

+234
-374
lines changed

11 files changed

+234
-374
lines changed

README.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,18 @@ pnpm add @vite-pwa/vitepress -D
5555

5656
## 🦄 Usage
5757

58-
You will need add or switch `defineConfig` from `VitePress` to `Vite Plugin PWA Integration for Vitepress`:
58+
You will need wrap your VitePress config with `withPwa`:
5959

6060
```ts
6161
// .vitepress/config.ts
62-
import { defineConfig } from '@vite-pwa/vitepress'
62+
import { defineConfig } from 'vitepress'
63+
import { withPwa } from '@vite-pwa/vitepress'
6364

64-
export default defineConfig({
65+
export default withPwa(defineConfig({
6566
/* your VitePress options */
6667
/* Vite PWA Options */
6768
pwa: {}
68-
})
69-
```
70-
71-
or just change the import:
72-
73-
```ts
74-
// .vitepress/config.ts
75-
// import { defineConfig } from 'vitepress' <== comment this line or switch the import
76-
import { defineConfig } from '@vite-pwa/vitepress' // <== add this line
77-
78-
export default defineConfig({
79-
/* your VitePress options */
80-
/* Vite PWA Options */
81-
pwa: {}
82-
})
69+
}))
8370
```
8471

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

examples/pwa-prompt/.vitepress/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { defineConfig } from '@vite-pwa/vitepress'
1+
import { defineConfig } from 'vitepress'
2+
import { withPwa } from '@vite-pwa/vitepress'
23

3-
export default defineConfig({
4+
export default withPwa(defineConfig({
45
vite: {
56
logLevel: 'info',
67
define: {
@@ -62,4 +63,4 @@ export default defineConfig({
6263
globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
6364
},
6465
},
65-
})
66+
}))

examples/pwa-simple/.vitepress/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { defineConfig } from '@vite-pwa/vitepress'
1+
import { defineConfig } from 'vitepress'
2+
import { withPwa } from '@vite-pwa/vitepress'
23

3-
export default defineConfig({
4+
export default withPwa(defineConfig({
45
vite: {
56
logLevel: 'info',
67
define: {
@@ -64,4 +65,4 @@ export default defineConfig({
6465
globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
6566
},
6667
},
67-
})
68+
}))

examples/pwa-simple/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"forceConsistentCasingInFileNames": true,
1515
"types": [
1616
"vite/client",
17-
"vitepress"
17+
"vitepress",
18+
"@vite-pwa/vitepress"
1819
]
1920
},
2021
"include": [

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@
4343
"release": "npx bumpp --push --tag --commit && npm publish"
4444
},
4545
"devDependencies": {
46-
"@antfu/eslint-config": "^0.26.3",
46+
"@antfu/eslint-config": "^0.27.0",
4747
"@antfu/ni": "^0.18.0",
4848
"@types/debug": "^4.1.7",
4949
"@types/workbox-build": "^5.0.1",
50-
"@typescript-eslint/eslint-plugin": "^5.36.2",
51-
"eslint": "^8.23.0",
50+
"@typescript-eslint/eslint-plugin": "^5.38.0",
51+
"eslint": "^8.23.1",
5252
"https-localhost": "^4.7.1",
5353
"typescript": "^4.8.3",
54-
"unbuild": "^0.8.10",
55-
"vite": "^3.1.0",
56-
"vite-plugin-pwa": "file:vite-plugin-pwa-0.12.8.tgz",
57-
"vitepress": "1.0.0-alpha.14"
54+
"unbuild": "^0.8.11",
55+
"vite": "^3.1.3",
56+
"vite-plugin-pwa": "file:vite-plugin-pwa-0.13.0.tgz",
57+
"vitepress": "1.0.0-alpha.15"
5858
},
5959
"pnpm": {
6060
"peerDependencyRules": {

0 commit comments

Comments
 (0)