-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add experimental PWA assets generation and injection (#30)
- Loading branch information
Showing
18 changed files
with
1,019 additions
and
178 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
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,65 @@ | ||
import { defineConfig } from 'vitepress' | ||
import { withPwa } from '@vite-pwa/vitepress' | ||
|
||
const base = '/' // '/vite-plugin-pwa/' | ||
|
||
export default withPwa(defineConfig({ | ||
vite: { | ||
logLevel: 'info', | ||
define: { | ||
__DATE__: `'${new Date().toISOString()}'`, | ||
}, | ||
}, | ||
base, | ||
lang: 'en-US', | ||
title: 'VitePress PWA', | ||
description: 'Vite Plugin PWA Integration example for VitePress', | ||
head: [ | ||
['meta', { | ||
name: 'keywords', | ||
content: 'PWA, VitePress, workbox, Vite, vite-plugin', | ||
}], | ||
], | ||
themeConfig: { | ||
footer: { | ||
message: 'Released under the MIT License.', | ||
copyright: 'Copyright © 2022-PRESENT Anthony Fu', | ||
}, | ||
nav: [ | ||
{ text: 'Home', link: '/' }, | ||
{ text: 'About', link: '/about', activeMatch: '/about' }, | ||
{ | ||
text: 'Packages', | ||
items: [ | ||
{ text: 'Foo', link: '/packages/foo' }, | ||
{ text: 'Bar', link: '/packages/bar' }, | ||
], | ||
}, | ||
], | ||
}, | ||
pwa: { | ||
mode: 'development', | ||
registerType: 'autoUpdate', | ||
injectRegister: 'script-defer', | ||
includeAssets: ['favicon.svg'], | ||
manifest: { | ||
name: 'VitePress PWA', | ||
short_name: 'VitePressPWA', | ||
theme_color: '#ffffff', | ||
}, | ||
pwaAssets: { | ||
config: true, | ||
}, | ||
workbox: { | ||
globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'], | ||
}, | ||
experimental: { | ||
includeAllowlist: true, | ||
}, | ||
devOptions: { | ||
enabled: false, | ||
suppressWarnings: true, | ||
navigateFallback: '/', | ||
}, | ||
}, | ||
})) |
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,10 @@ | ||
--- | ||
title: About | ||
--- | ||
<script setup> | ||
const date = __DATE__ | ||
</script> | ||
|
||
# About | ||
|
||
<pre>Generated at: {{ date }}</pre> |
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,12 @@ | ||
--- | ||
title: VitePress PWA | ||
titleTemplate: Zero-config PWA Plugin for VitePress | ||
--- | ||
|
||
<script setup> | ||
const date = __DATE__ | ||
</script> | ||
|
||
# VitePress PWA | ||
|
||
<pre>Generated at: {{ date }}</pre> |
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,17 @@ | ||
{ | ||
"name": "pwa-simple", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"private": "true", | ||
"scripts": { | ||
"dev": "vitepress dev", | ||
"build": "vitepress build", | ||
"preview": "nr build && vitepress serve", | ||
"https": "nr build && serve .vitepress/dist" | ||
}, | ||
"devDependencies": { | ||
"@vite-pwa/vitepress": "workspace:*", | ||
"https-localhost": "^4.7.1", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
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,11 @@ | ||
--- | ||
title: Package | ||
--- | ||
|
||
<script setup> | ||
const date = __DATE__ | ||
</script> | ||
|
||
# Package `{{ $params.pkg }}` | ||
|
||
<pre>Generated at: {{ date }}</pre> |
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,8 @@ | ||
export default { | ||
paths() { | ||
return [ | ||
{ params: { pkg: 'foo' } }, | ||
{ params: { pkg: 'bar' } }, | ||
] | ||
}, | ||
} |
Empty file.
130 changes: 130 additions & 0 deletions
130
examples/pwa-simple-assets-generator/public/favicon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
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,25 @@ | ||
import { | ||
createAppleSplashScreens, | ||
defineConfig, | ||
minimal2023Preset, | ||
} from '@vite-pwa/assets-generator/config' | ||
|
||
export default defineConfig({ | ||
headLinkOptions: { | ||
preset: '2023', | ||
}, | ||
preset: { | ||
...minimal2023Preset, | ||
appleSplashScreens: createAppleSplashScreens({ | ||
padding: 0.3, | ||
resizeOptions: { fit: 'contain', background: 'white' }, | ||
darkResizeOptions: { fit: 'contain', background: 'black' }, | ||
linkMediaOptions: { | ||
log: true, | ||
addMediaScreen: true, | ||
xhtml: true, | ||
}, | ||
}, ['iPad Air 9.7"']), | ||
}, | ||
images: 'public/favicon.svg', | ||
}) |
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,27 @@ | ||
{ | ||
"compilerOptions": { | ||
"incremental": false, | ||
"target": "ESNext", | ||
"lib": ["DOM", "ESNext"], | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"baseUrl": ".", | ||
"types": [ | ||
"vite/client", | ||
"vitepress", | ||
"@vite-pwa/vitepress" | ||
], | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"./*.ts", | ||
"./.vitepress/**/*.ts", | ||
"./.vitepress/**/*.vue" | ||
], | ||
"exclude": ["dist", "node_modules"] | ||
} |
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 @@ | ||
declare const __DATE__: string |
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.