@vite-pwa/vitepress 0.0.5 → 0.2.0
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/LICENSE +1 -1
- package/README.md +3 -1
- package/dist/index.cjs +16 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.mjs +16 -8
- package/package.json +14 -15
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022 Anthony Fu<https://github.com/antfu>
|
|
3
|
+
Copyright (c) 2022-PRESENT Anthony Fu <https://github.com/antfu>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -40,6 +40,8 @@ Zero-config PWA Plugin for VitePress
|
|
|
40
40
|
- ⚙️ **Stale-while-revalidate**: automatic reload when new content is available
|
|
41
41
|
- ✨ **Static assets handling**: configure static assets for offline support
|
|
42
42
|
- 🐞 **Development Support**: debug your custom service worker logic as you develop your application
|
|
43
|
+
- 🛠️ **Versatile**: integration with meta frameworks: [îles](https://github.com/ElMassimo/iles), [SvelteKit](https://github.com/sveltejs/kit), [VitePress](https://github.com/vuejs/vitepress), [Astro](https://github.com/withastro/astro), and [Nuxt 3](https://github.com/nuxt/nuxt)
|
|
44
|
+
- 💥 PWA Assets Generator: generate all the PWA assets from a single command and a single source image
|
|
43
45
|
|
|
44
46
|
## 📦 Install
|
|
45
47
|
|
|
@@ -84,4 +86,4 @@ Check out the type declaration [src/types.ts](./src/types.ts) and the following
|
|
|
84
86
|
|
|
85
87
|
## 📄 License
|
|
86
88
|
|
|
87
|
-
MIT License
|
|
89
|
+
[MIT](./LICENSE) License © 2022-PRESENT [Anthony Fu](https://github.com/antfu)
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const vitepress = require('vitepress');
|
|
4
3
|
const vitePluginPwa = require('vite-plugin-pwa');
|
|
5
4
|
|
|
6
5
|
function configurePWAOptions(options) {
|
|
@@ -17,7 +16,7 @@ function configurePWAOptions(options) {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
function
|
|
19
|
+
function withUserConfig(config) {
|
|
21
20
|
let viteConf = config.vite;
|
|
22
21
|
if (!viteConf) {
|
|
23
22
|
viteConf = {};
|
|
@@ -33,23 +32,22 @@ function withPwa(config) {
|
|
|
33
32
|
if (pwaPlugin)
|
|
34
33
|
throw new Error("Remove vite-plugin-pwa plugin from Vite Plugins entry in VitePress config file");
|
|
35
34
|
}
|
|
36
|
-
const { pwa = {}
|
|
35
|
+
const { pwa = {} } = config;
|
|
37
36
|
configurePWAOptions(pwa);
|
|
38
37
|
let api;
|
|
39
38
|
vitePlugins.push(
|
|
40
|
-
// @ts-expect-error vite 4 PluginOption and Plugin mismatch
|
|
41
39
|
vitePluginPwa.VitePWA({ ...pwa }),
|
|
42
40
|
{
|
|
43
41
|
name: "vite-plugin-pwa:vitepress",
|
|
44
42
|
apply: "build",
|
|
45
43
|
enforce: "post",
|
|
46
|
-
configResolved(
|
|
47
|
-
if (!
|
|
48
|
-
api =
|
|
44
|
+
configResolved(resolvedViteConfig) {
|
|
45
|
+
if (!resolvedViteConfig.build.ssr)
|
|
46
|
+
api = resolvedViteConfig.plugins.find((p) => p.name === "vite-plugin-pwa")?.api;
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
);
|
|
52
|
-
const vitePressConfig =
|
|
50
|
+
const vitePressConfig = config;
|
|
53
51
|
const userTransformHead = vitePressConfig.transformHead;
|
|
54
52
|
const userBuildEnd = vitePressConfig.buildEnd;
|
|
55
53
|
vitePressConfig.transformHead = async (ctx) => {
|
|
@@ -89,4 +87,14 @@ function withPwa(config) {
|
|
|
89
87
|
return vitePressConfig;
|
|
90
88
|
}
|
|
91
89
|
|
|
90
|
+
async function withPwa(config) {
|
|
91
|
+
if (typeof config === "function") {
|
|
92
|
+
return async (ctx) => {
|
|
93
|
+
const userConfig = await config(ctx);
|
|
94
|
+
return withUserConfig(userConfig);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return withUserConfig(await config);
|
|
98
|
+
}
|
|
99
|
+
|
|
92
100
|
exports.withPwa = withPwa;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import * as vitepress_dist_node from 'vitepress/dist/node';
|
|
3
|
+
import { DefaultTheme, UserConfigExport } from 'vitepress';
|
|
2
4
|
import { VitePWAOptions } from 'vite-plugin-pwa';
|
|
3
5
|
|
|
4
|
-
interface PwaOptions extends Partial<VitePWAOptions> {
|
|
5
|
-
}
|
|
6
|
-
declare module 'vitepress' {
|
|
7
|
-
interface UserConfig {
|
|
8
|
-
pwa?: PwaOptions;
|
|
9
|
-
}
|
|
6
|
+
interface PwaOptions extends Partial<VitePWAOptions> {
|
|
7
|
+
}
|
|
8
|
+
declare module 'vitepress' {
|
|
9
|
+
interface UserConfig {
|
|
10
|
+
pwa?: PwaOptions;
|
|
11
|
+
}
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
declare function withPwa(config:
|
|
14
|
+
declare function withPwa<T = DefaultTheme.Config>(config: UserConfigExport<T>): Promise<vitepress_dist_node.UserConfig<T> | ((ctx: vite.ConfigEnv) => Promise<vitepress_dist_node.UserConfig<T>>)>;
|
|
13
15
|
|
|
14
16
|
export { PwaOptions, withPwa };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { defineConfigWithTheme } from 'vitepress';
|
|
2
1
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
3
2
|
|
|
4
3
|
function configurePWAOptions(options) {
|
|
@@ -15,7 +14,7 @@ function configurePWAOptions(options) {
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
function
|
|
17
|
+
function withUserConfig(config) {
|
|
19
18
|
let viteConf = config.vite;
|
|
20
19
|
if (!viteConf) {
|
|
21
20
|
viteConf = {};
|
|
@@ -31,23 +30,22 @@ function withPwa(config) {
|
|
|
31
30
|
if (pwaPlugin)
|
|
32
31
|
throw new Error("Remove vite-plugin-pwa plugin from Vite Plugins entry in VitePress config file");
|
|
33
32
|
}
|
|
34
|
-
const { pwa = {}
|
|
33
|
+
const { pwa = {} } = config;
|
|
35
34
|
configurePWAOptions(pwa);
|
|
36
35
|
let api;
|
|
37
36
|
vitePlugins.push(
|
|
38
|
-
// @ts-expect-error vite 4 PluginOption and Plugin mismatch
|
|
39
37
|
VitePWA({ ...pwa }),
|
|
40
38
|
{
|
|
41
39
|
name: "vite-plugin-pwa:vitepress",
|
|
42
40
|
apply: "build",
|
|
43
41
|
enforce: "post",
|
|
44
|
-
configResolved(
|
|
45
|
-
if (!
|
|
46
|
-
api =
|
|
42
|
+
configResolved(resolvedViteConfig) {
|
|
43
|
+
if (!resolvedViteConfig.build.ssr)
|
|
44
|
+
api = resolvedViteConfig.plugins.find((p) => p.name === "vite-plugin-pwa")?.api;
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
);
|
|
50
|
-
const vitePressConfig =
|
|
48
|
+
const vitePressConfig = config;
|
|
51
49
|
const userTransformHead = vitePressConfig.transformHead;
|
|
52
50
|
const userBuildEnd = vitePressConfig.buildEnd;
|
|
53
51
|
vitePressConfig.transformHead = async (ctx) => {
|
|
@@ -87,4 +85,14 @@ function withPwa(config) {
|
|
|
87
85
|
return vitePressConfig;
|
|
88
86
|
}
|
|
89
87
|
|
|
88
|
+
async function withPwa(config) {
|
|
89
|
+
if (typeof config === "function") {
|
|
90
|
+
return async (ctx) => {
|
|
91
|
+
const userConfig = await config(ctx);
|
|
92
|
+
return withUserConfig(userConfig);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return withUserConfig(await config);
|
|
96
|
+
}
|
|
97
|
+
|
|
90
98
|
export { withPwa };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-pwa/vitepress",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"packageManager": "pnpm@8.6.1",
|
|
6
6
|
"description": "Zero-config PWA for VitePress",
|
|
7
7
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -43,22 +43,21 @@
|
|
|
43
43
|
"release": "bumpp && npm publish"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"vite-plugin-pwa": "
|
|
46
|
+
"vite-plugin-pwa": ">=0.16.3 <1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@antfu/eslint-config": "^0.
|
|
50
|
-
"@antfu/ni": "^0.
|
|
51
|
-
"@types/debug": "^4.1.
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"eslint": "^8.33.0",
|
|
49
|
+
"@antfu/eslint-config": "^0.39.5",
|
|
50
|
+
"@antfu/ni": "^0.21.4",
|
|
51
|
+
"@types/debug": "^4.1.8",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.59.9",
|
|
53
|
+
"bumpp": "^9.1.1",
|
|
54
|
+
"eslint": "^8.42.0",
|
|
56
55
|
"https-localhost": "^4.7.1",
|
|
57
|
-
"typescript": "^
|
|
58
|
-
"unbuild": "^1.
|
|
59
|
-
"vite": "^4.
|
|
60
|
-
"vite-plugin-pwa": "
|
|
61
|
-
"vitepress": "1.0.0-
|
|
56
|
+
"typescript": "^5.1.3",
|
|
57
|
+
"unbuild": "^1.2.1",
|
|
58
|
+
"vite": "^4.3.9",
|
|
59
|
+
"vite-plugin-pwa": ">=0.16.3 <1",
|
|
60
|
+
"vitepress": "1.0.0-beta.2"
|
|
62
61
|
},
|
|
63
62
|
"pnpm": {
|
|
64
63
|
"peerDependencyRules": {
|