Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
2,601 additions
and
3,060 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends": "@antfu", | ||
"extends": ["@antfu"], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ignore-workspace-root-check=true | ||
shamefully-hoist=true | ||
strict-peer-dependencies=false | ||
auto-install-peers=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,7 @@ export default defineConfig({ | |
/* other options */ | ||
} | ||
}) | ||
] | ||
] | ||
}) | ||
``` | ||
::: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { resolveConfig } from 'vite' | ||
import type { VitePluginPWAAPI } from '../../dist' | ||
import type { VitePluginPWAAPI } from 'vite-plugin-pwa' | ||
import { optimizePages } from './assets' | ||
import { pwa } from './pwa' | ||
|
||
const rebuildPwa = async () => { | ||
const config = await resolveConfig({}, 'build', 'production') | ||
export const buildEnd = async () => { | ||
await optimizePages() | ||
const config = await resolveConfig({ plugins: [pwa()] }, 'build', 'production') | ||
// when `vite-plugin-pwa` is presented, use it to regenerate SW after rendering | ||
const pwaPlugin: VitePluginPWAAPI = config.plugins.find(i => i.name === 'vite-plugin-pwa')?.api | ||
if (pwaPlugin && pwaPlugin.generateSW && !pwaPlugin.disabled) { | ||
await optimizePages() | ||
if (pwaPlugin && pwaPlugin.generateSW && !pwaPlugin.disabled) | ||
await pwaPlugin.generateSW() | ||
} | ||
} | ||
|
||
rebuildPwa() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { VitePWA } from 'vite-plugin-pwa' | ||
|
||
export const pwa = () => { | ||
return VitePWA({ | ||
outDir: '.vitepress/dist', | ||
registerType: 'prompt', | ||
includeManifestIcons: false, | ||
manifest: { | ||
id: '/', | ||
name: 'Vite Plugin PWA', | ||
short_name: 'PWA for Vite', | ||
description: 'Zero-config PWA for Vite', | ||
theme_color: '#ffffff', | ||
icons: [ | ||
{ | ||
src: 'pwa-192x192.png', | ||
sizes: '192x192', | ||
type: 'image/png', | ||
}, | ||
{ | ||
src: 'pwa-512x512.png', | ||
sizes: '512x512', | ||
type: 'image/png', | ||
}, | ||
{ | ||
src: 'icon_light.svg', | ||
sizes: '155x155', | ||
type: 'image/svg', | ||
purpose: 'any maskable', | ||
}, | ||
], | ||
}, | ||
workbox: { | ||
globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'], | ||
runtimeCaching: [ | ||
{ | ||
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i, | ||
handler: 'CacheFirst', | ||
options: { | ||
cacheName: 'google-fonts-cache', | ||
expiration: { | ||
maxEntries: 10, | ||
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days | ||
}, | ||
cacheableResponse: { | ||
statuses: [0, 200], | ||
}, | ||
}, | ||
}, | ||
{ | ||
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i, | ||
handler: 'CacheFirst', | ||
options: { | ||
cacheName: 'gstatic-fonts-cache', | ||
expiration: { | ||
maxEntries: 10, | ||
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days | ||
}, | ||
cacheableResponse: { | ||
statuses: [0, 200], | ||
}, | ||
}, | ||
}, | ||
{ | ||
urlPattern: /^https:\/\/cdn\.jsdelivr\.net\/.*/i, | ||
handler: 'NetworkFirst', | ||
options: { | ||
cacheName: 'jsdelivr-images-cache', | ||
expiration: { | ||
maxEntries: 10, | ||
maxAgeSeconds: 60 * 60 * 24 * 7, // <== 7 days | ||
}, | ||
cacheableResponse: { | ||
statuses: [0, 200], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.