diff options
Diffstat (limited to 'examples/with-vite-plugin-pwa')
-rw-r--r-- | examples/with-vite-plugin-pwa/.gitignore | 18 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/.npmrc | 2 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/.stackblitzrc | 6 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/README.md | 43 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/astro.config.mjs | 16 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/package.json | 15 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/public/favicon.ico | bin | 0 -> 4286 bytes | |||
-rw-r--r-- | examples/with-vite-plugin-pwa/public/robots.txt | 2 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/sandbox.config.json | 11 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/src/index.ts | 10 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/src/pages/index.astro | 18 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/src/vite-env.d.ts | 11 | ||||
-rw-r--r-- | examples/with-vite-plugin-pwa/tsconfig.json | 3 |
13 files changed, 155 insertions, 0 deletions
diff --git a/examples/with-vite-plugin-pwa/.gitignore b/examples/with-vite-plugin-pwa/.gitignore new file mode 100644 index 000000000..d436c6dad --- /dev/null +++ b/examples/with-vite-plugin-pwa/.gitignore @@ -0,0 +1,18 @@ +# build output +dist + +# dependencies +node_modules/ +.snowpack/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store diff --git a/examples/with-vite-plugin-pwa/.npmrc b/examples/with-vite-plugin-pwa/.npmrc new file mode 100644 index 000000000..65922326b --- /dev/null +++ b/examples/with-vite-plugin-pwa/.npmrc @@ -0,0 +1,2 @@ +## force pnpm to hoist +shamefully-hoist = true diff --git a/examples/with-vite-plugin-pwa/.stackblitzrc b/examples/with-vite-plugin-pwa/.stackblitzrc new file mode 100644 index 000000000..43798ecff --- /dev/null +++ b/examples/with-vite-plugin-pwa/.stackblitzrc @@ -0,0 +1,6 @@ +{ + "startCommand": "npm start", + "env": { + "ENABLE_CJS_IMPORTS": true + } +}
\ No newline at end of file diff --git a/examples/with-vite-plugin-pwa/README.md b/examples/with-vite-plugin-pwa/README.md new file mode 100644 index 000000000..b078cf708 --- /dev/null +++ b/examples/with-vite-plugin-pwa/README.md @@ -0,0 +1,43 @@ +# Astro Starter Kit: Minimal + +``` +npm init astro -- --template minimal +``` + +[](https://stackblitz.com/github/snowpackjs/astro/tree/latest/examples/minimal) + +> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun! + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +``` +/ +├── public/ +├── src/ +│ └── pages/ +│ └── index.astro +└── package.json +``` + +Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. + +There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. + +Any static assets, like images, can be placed in the `public/` directory. + +## 🧞 Commands + +All commands are run from the root of the project, from a terminal: + +| Command | Action | +|:---------------- |:-------------------------------------------- | +| `npm install` | Installs dependencies | +| `npm run dev` | Starts local dev server at `localhost:3000` | +| `npm run build` | Build your production site to `./dist/` | +| `npm run preview` | Preview your build locally, before deploying | + +## 👀 Want to learn more? + +Feel free to check [our documentation](https://github.com/snowpackjs/astro) or jump into our [Discord server](https://astro.build/chat). diff --git a/examples/with-vite-plugin-pwa/astro.config.mjs b/examples/with-vite-plugin-pwa/astro.config.mjs new file mode 100644 index 000000000..29194f9d6 --- /dev/null +++ b/examples/with-vite-plugin-pwa/astro.config.mjs @@ -0,0 +1,16 @@ +import { VitePWA } from 'vite-plugin-pwa' + +// Full Astro Configuration API Documentation: +// https://docs.astro.build/reference/configuration-reference + +// @type-check enabled! +// VSCode and other TypeScript-enabled text editors will provide auto-completion, +// helpful tooltips, and warnings if your exported object is invalid. +// You can disable this by removing "@ts-check" and `@type` comments below. + +// @ts-check +export default /** @type {import('astro').AstroUserConfig} */ ({ + vite: { + plugins: [VitePWA()] + } +}); diff --git a/examples/with-vite-plugin-pwa/package.json b/examples/with-vite-plugin-pwa/package.json new file mode 100644 index 000000000..4b741c78a --- /dev/null +++ b/examples/with-vite-plugin-pwa/package.json @@ -0,0 +1,15 @@ +{ + "name": "@example/with-vite-plugin-pwa", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview" + }, + "devDependencies": { + "astro": "^0.21.0-next.3", + "vite-plugin-pwa": "^0.11.5" + } +} diff --git a/examples/with-vite-plugin-pwa/public/favicon.ico b/examples/with-vite-plugin-pwa/public/favicon.ico Binary files differnew file mode 100644 index 000000000..578ad458b --- /dev/null +++ b/examples/with-vite-plugin-pwa/public/favicon.ico diff --git a/examples/with-vite-plugin-pwa/public/robots.txt b/examples/with-vite-plugin-pwa/public/robots.txt new file mode 100644 index 000000000..1f53798bb --- /dev/null +++ b/examples/with-vite-plugin-pwa/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/examples/with-vite-plugin-pwa/sandbox.config.json b/examples/with-vite-plugin-pwa/sandbox.config.json new file mode 100644 index 000000000..9178af77d --- /dev/null +++ b/examples/with-vite-plugin-pwa/sandbox.config.json @@ -0,0 +1,11 @@ +{ + "infiniteLoopProtection": true, + "hardReloadOnChange": false, + "view": "browser", + "template": "node", + "container": { + "port": 3000, + "startScript": "start", + "node": "14" + } +} diff --git a/examples/with-vite-plugin-pwa/src/index.ts b/examples/with-vite-plugin-pwa/src/index.ts new file mode 100644 index 000000000..af679697f --- /dev/null +++ b/examples/with-vite-plugin-pwa/src/index.ts @@ -0,0 +1,10 @@ +import { registerSW } from 'virtual:pwa-register' + +const updateSW = registerSW({ + onNeedRefresh() {}, + onOfflineReady() { + console.log("Offline ready"); + } +}) + +updateSW(); diff --git a/examples/with-vite-plugin-pwa/src/pages/index.astro b/examples/with-vite-plugin-pwa/src/pages/index.astro new file mode 100644 index 000000000..008442824 --- /dev/null +++ b/examples/with-vite-plugin-pwa/src/pages/index.astro @@ -0,0 +1,18 @@ +--- +--- + +<html lang="en"> + +<head> + <meta charset="utf-8" /> + <link rel="icon" type="image/x-icon" href="/favicon.ico" /> + <meta name="viewport" content="width=device-width" /> + <title>Welcome to Astro</title> +</head> + +<body> + <h1>Welcome to <a href="https://astro.build/">Astro</a></h1> + <script src={Astro.resolve('../index.ts')} type="module" hoist /> +</body> + +</html> diff --git a/examples/with-vite-plugin-pwa/src/vite-env.d.ts b/examples/with-vite-plugin-pwa/src/vite-env.d.ts new file mode 100644 index 000000000..6b2c10cd8 --- /dev/null +++ b/examples/with-vite-plugin-pwa/src/vite-env.d.ts @@ -0,0 +1,11 @@ +declare module 'virtual:pwa-register' { + export type RegisterSWOptions = { + immediate?: boolean + onNeedRefresh?: () => void + onOfflineReady?: () => void + onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void + onRegisterError?: (error: any) => void + } + + export function registerSW(options?: RegisterSWOptions): (reloadPage?: boolean) => Promise<void> +} diff --git a/examples/with-vite-plugin-pwa/tsconfig.json b/examples/with-vite-plugin-pwa/tsconfig.json new file mode 100644 index 000000000..5d9f97afe --- /dev/null +++ b/examples/with-vite-plugin-pwa/tsconfig.json @@ -0,0 +1,3 @@ +{ + "include": ["src/**/*.ts"] +} |