-
Notifications
You must be signed in to change notification settings - Fork 1
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
30 changed files
with
3,435 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], | ||
plugins: ['svelte3', '@typescript-eslint'], | ||
ignorePatterns: ['*.cjs'], | ||
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], | ||
settings: { | ||
'svelte3/typescript': () => require('typescript') | ||
}, | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaVersion: 2019 | ||
}, | ||
env: { | ||
browser: true, | ||
es2017: true, | ||
node: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
.env |
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,6 @@ | ||
{ | ||
"useTabs": true, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"printWidth": 100 | ||
} |
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,2 +1,22 @@ | ||
# sveltekit-isr | ||
Incremental static regeneration for SvelteKit on Cloudflare Workers | ||
# Incremental static regeneration (ISR) for SvelteKit on Cloudflare Pages | ||
|
||
This is a small Covid19 Tracker demo that uses SvelteKit to show that Cloudflare supports framework-agnostic Incremental Static Regeneration (ISR).<br> | ||
The homepage is regenerated every 24 hours, while the country pages are regenerated every 4 hours.<br> | ||
If you inspect the page response headers, you can see that even if there has been a cache miss, the response still contains a stale version. | ||
|
||
## What is ISR? | ||
|
||
The acronym has been coined by Vercel, and it's a method of rendering static pages on demand instead of generating all pages at build time like a normal SSG does. This allows websites with thousands of pages to keep build times low.<br> | ||
NextJS has built-in support for ISR when deployed on Vercel. | ||
|
||
You can read more about ISR on [Vercel official documentation](https://vercel.com/docs/concepts/next.js/incremental-static-regeneration) | ||
|
||
## How do you achieve ISR on Cloudflare? | ||
|
||
For a framework-agnostic and detailed explanation, please read my [blog post](https://reego.dev/blog/isr-on-cloudflare-pages). | ||
|
||
If you are just curious about SvelteKit implementation, check the [adapter](https://github.com/reegodev/sveltekit-isr/tree/main/adapter) folder. | ||
|
||
## License | ||
|
||
MIT |
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,19 @@ | ||
export default function ({ pages = 'build', assets = pages, fallback } = {}) { | ||
return { | ||
name: 'cloudflare-pages-isr-adapter', | ||
|
||
async adapt({ utils }) { | ||
utils.rimraf(assets); | ||
utils.rimraf(pages); | ||
|
||
utils.copy_static_files(assets); | ||
utils.copy_client_files(assets); | ||
|
||
await utils.prerender({ | ||
fallback, | ||
all: !fallback, | ||
dest: pages | ||
}); | ||
} | ||
}; | ||
} |
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 @@ | ||
\[\[path\]\].js |
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,40 @@ | ||
{ | ||
"name": "my-app", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"dev": "svelte-kit dev", | ||
"build": "svelte-kit build", | ||
"preview": "svelte-kit preview", | ||
"check": "svelte-check --tsconfig ./tsconfig.json", | ||
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", | ||
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", | ||
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ." | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/kit": "next", | ||
"@typescript-eslint/eslint-plugin": "^4.31.1", | ||
"@typescript-eslint/parser": "^4.31.1", | ||
"autoprefixer": "^10.4.0", | ||
"cssnano": "^5.0.11", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-svelte3": "^3.2.1", | ||
"postcss": "^8.3.11", | ||
"prettier": "^2.4.1", | ||
"prettier-plugin-svelte": "^2.4.0", | ||
"svelte": "^3.42.6", | ||
"svelte-check": "^2.2.6", | ||
"svelte-preprocess": "^4.9.4", | ||
"tailwindcss": "^2.2.19", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.3" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"@cloudflare/kv-asset-handler": "^0.2.0", | ||
"axios": "^0.24.0", | ||
"date-fns": "^2.26.0", | ||
"simple-svelte-autocomplete": "^2.2.4", | ||
"svelte-autocomplete": "^0.0.4" | ||
} | ||
} |
Oops, something went wrong.