Repository: tretapey/svelte-pwa
Branch: master
Commit: 6958525b5ba8
Files: 11
Total size: 9.8 KB
Directory structure:
gitextract_gmx67wy7/
├── .gitignore
├── README.md
├── package.json
├── public/
│ ├── global.css
│ ├── index.html
│ ├── manifest.json
│ ├── offline.html
│ └── service-worker.js
├── rollup.config.js
└── src/
├── App.svelte
└── main.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/node_modules/
/public/build/
.DS_Store
================================================
FILE: README.md
================================================
---
# Svelte PWA
This is a Progressive Web App (PWA) template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/tretapey/svelte-pwa.
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
```bash
npx degit tretapey/svelte-pwa my-svelte-pwa
cd my-svelte-pwa
```
_Note that you will need to have [Node.js](https://nodejs.org) installed._
## Get started
Install the dependencies...
```bash
cd my-svelte-pwa
npm install
```
...then start [Rollup](https://rollupjs.org):
```bash
npm run dev
```
Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
## PWA Configuration
- The `service-worker.js` and `manifest.json` files are in the `public` folder.
- You should update the icons in `/public/images/icons`
- For an offline experience edit the `/public/offline.html` file.
- This PWA is installable. For more information on how to use check [this repo](https://github.com/pwa-builder/pwa-install).
Note: If you don't want to make the app installable you can remove the script from the `index.html` file in the `public` folder.
For more info, this template was made following this [tutorial](https://codelabs.developers.google.com/codelabs/your-first-pwapp)
## Building and running in production mode
To create an optimised version of the app:
```bash
npm run build
```
================================================
FILE: package.json
================================================
{
"name": "svelte-pwa-template",
"version": "1.0.4",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public",
"test": "echo test"
},
"devDependencies": {
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-node-resolve": "^7.0.0",
"rollup": "^1.20.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-svelte": "^6.1.1",
"rollup-plugin-terser": "^7.0.1",
"svelte": "^3.49.0"
},
"dependencies": {
"sirv-cli": "^0.4.4"
}
}
================================================
FILE: public/global.css
================================================
html, body {
position: relative;
width: 100%;
height: 100%;
}
body {
color: #333;
margin: 0;
padding: 8px;
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
a {
color: rgb(0,100,200);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:visited {
color: rgb(0,80,160);
}
label {
display: block;
}
input, button, select, textarea {
font-family: inherit;
font-size: inherit;
padding: 0.4em;
margin: 0 0 0.5em 0;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 2px;
}
input:disabled {
color: #ccc;
}
input[type="range"] {
height: 0;
}
button {
color: #333;
background-color: #f4f4f4;
outline: none;
}
button:disabled {
color: #999;
}
button:not(:disabled):active {
background-color: #ddd;
}
button:focus {
border-color: #666;
}
================================================
FILE: public/index.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Svelte PWA</title>
<link rel="manifest" href="/manifest.json" />
<meta name="description" content="Svelte PWA starter template" />
<meta name="theme-color" content="#2F3BA2" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="Svelte PWA" />
<link rel="apple-touch-icon" href="/images/icons/icon-152x152.png" />
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="stylesheet" href="/global.css" />
<link rel="stylesheet" href="/build/bundle.css" />
<!-- You can remove this is you don't want to make your PWA installable -->
<script
type="module"
src="https://cdn.jsdelivr.net/npm/@pwabuilder/pwainstall"
></script>
<script defer src="/build/bundle.js"></script>
</head>
<body>
<noscript>
<div>Oops! Javascript required here! Allow it and try again!</div>
</noscript>
<script>
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker.register("/service-worker.js").then((reg) => {
console.log("Service worker registered.", reg);
});
});
}
</script>
</body>
</html>
================================================
FILE: public/manifest.json
================================================
{
"name": "SVELTE-PWA",
"short_name": "SVELTE-PWA",
"icons": [
{
"src": "/images/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "/images/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "/images/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "/images/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/images/icons/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/images/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "/images/icons/maskable_icon.png",
"sizes": "640x640",
"type": "image/png",
"purpose": "any maskable"
}
],
"start_url": "/index.html",
"display": "standalone",
"background_color": "#3E4EB8",
"theme_color": "#2F3BA2"
}
================================================
FILE: public/offline.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name='viewport' content='width=device-width,initial-scale=1.0'>
<title>Svelte PWA</title>
<link rel="manifest" href="/manifest.json">
<meta name="description" content="Svelte PWA starter template">
<meta name="theme-color" content="#2F3BA2" />
</head>
<body>
<div>
Oops, you appear to be offline, this app requires an internet
connection.
</div>
</body>
</html>
================================================
FILE: public/service-worker.js
================================================
'use strict';
// Update cache names any time any of the cached files change.
const CACHE_NAME = 'static-cache-v1';
// Add list of files to cache here.
const FILES_TO_CACHE = [
'/offline.html',
];
self.addEventListener('install', (evt) => {
console.log('[ServiceWorker] Install');
evt.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
console.log('[ServiceWorker] Pre-caching offline page');
return cache.addAll(FILES_TO_CACHE);
})
);
self.skipWaiting();
});
self.addEventListener('activate', (evt) => {
console.log('[ServiceWorker] Activate');
// Remove previous cached data from disk.
evt.waitUntil(
caches.keys().then((keyList) => {
return Promise.all(keyList.map((key) => {
if (key !== CACHE_NAME) {
console.log('[ServiceWorker] Removing old cache', key);
return caches.delete(key);
}
}));
})
);
self.clients.claim();
});
self.addEventListener('fetch', (evt) => {
console.log('[ServiceWorker] Fetch', evt.request.url);
// Add fetch event handler here.
if (evt.request.mode !== 'navigate') {
// Not a page navigation, bail.
return;
}
evt.respondWith(
fetch(evt.request)
.catch(() => {
return caches.open(CACHE_NAME)
.then((cache) => {
return cache.match('offline.html');
});
})
);
});
================================================
FILE: rollup.config.js
================================================
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file - better for performance
css: css => {
css.write('public/build/bundle.css');
}
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};
function serve() {
let started = false;
return {
writeBundle() {
if (!started) {
started = true;
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
}
}
};
}
================================================
FILE: src/App.svelte
================================================
<script>
export let name;
</script>
<main>
<h1>Hello {name}!</h1>
<p>This is a starter template for a Svelte PWA, based in the <a href="https://github.com/sveltejs/template" target="_blank">Svelte template</a></p>
<p>You will find the manifest.json file and the service-worker.js file in the public folder</p>
<p>To update the proper icons for the PWA check <i>/public/images/icons</i></p>
</main>
<style>
main {
text-align: center;
padding: 1em;
max-width: 240px;
margin: 0 auto;
}
h1 {
color: #ff3e00;
text-transform: uppercase;
font-size: 4em;
font-weight: 100;
}
@media (min-width: 640px) {
main {
max-width: none;
}
}
</style>
================================================
FILE: src/main.js
================================================
import App from './App.svelte';
const app = new App({
target: document.body,
props: {
name: 'world'
}
});
export default app;
gitextract_gmx67wy7/
├── .gitignore
├── README.md
├── package.json
├── public/
│ ├── global.css
│ ├── index.html
│ ├── manifest.json
│ ├── offline.html
│ └── service-worker.js
├── rollup.config.js
└── src/
├── App.svelte
└── main.js
SYMBOL INDEX (3 symbols across 2 files)
FILE: public/service-worker.js
constant CACHE_NAME (line 4) | const CACHE_NAME = 'static-cache-v1';
constant FILES_TO_CACHE (line 7) | const FILES_TO_CACHE = [
FILE: rollup.config.js
function serve (line 56) | function serve() {
Condensed preview — 11 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (11K chars).
[
{
"path": ".gitignore",
"chars": 41,
"preview": "/node_modules/\n/public/build/\n\n.DS_Store\n"
},
{
"path": "README.md",
"chars": 1655,
"preview": "---\n\n# Svelte PWA\n\nThis is a Progressive Web App (PWA) template for [Svelte](https://svelte.dev) apps. It lives at https"
},
{
"path": "package.json",
"chars": 514,
"preview": "{\n \"name\": \"svelte-pwa-template\",\n \"version\": \"1.0.4\",\n \"scripts\": {\n \"build\": \"rollup -c\",\n \"dev\": \"rollup -c "
},
{
"path": "public/global.css",
"chars": 900,
"preview": "html, body {\n\tposition: relative;\n\twidth: 100%;\n\theight: 100%;\n}\n\nbody {\n\tcolor: #333;\n\tmargin: 0;\n\tpadding: 8px;\n\tbox-s"
},
{
"path": "public/index.html",
"chars": 1472,
"preview": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-w"
},
{
"path": "public/manifest.json",
"chars": 1015,
"preview": "{\n \"name\": \"SVELTE-PWA\",\n \"short_name\": \"SVELTE-PWA\",\n \"icons\": [\n {\n \"src\": \"/images/icons/icon-128x128.png\""
},
{
"path": "public/offline.html",
"chars": 544,
"preview": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset='utf-8'>\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE="
},
{
"path": "public/service-worker.js",
"chars": 1426,
"preview": "'use strict';\n\n// Update cache names any time any of the cached files change.\nconst CACHE_NAME = 'static-cache-v1';\n\n// "
},
{
"path": "rollup.config.js",
"chars": 1709,
"preview": "import svelte from 'rollup-plugin-svelte';\nimport resolve from '@rollup/plugin-node-resolve';\nimport commonjs from '@rol"
},
{
"path": "src/App.svelte",
"chars": 670,
"preview": "<script>\n\texport let name;\n</script>\n\n<main>\n\t<h1>Hello {name}!</h1>\n\t<p>This is a starter template for a Svelte PWA, ba"
},
{
"path": "src/main.js",
"chars": 132,
"preview": "import App from './App.svelte';\n\nconst app = new App({\n\ttarget: document.body,\n\tprops: {\n\t\tname: 'world'\n\t}\n});\n\nexport "
}
]
About this extraction
This page contains the full source code of the tretapey/svelte-pwa GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 11 files (9.8 KB), approximately 3.1k tokens, and a symbol index with 3 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.