From 319a10b9a106e768ea2d3fb6d7134817911208ce Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 13 Sep 2023 16:04:12 -0500 Subject: Add basic PWA support TODO: draw the rest of the owl --- app/src/app.d.ts | 8 ++++---- app/src/app.html | 20 ++++++++++---------- app/src/app.postcss | 2 +- app/src/hooks.server.ts | 35 +++++++++++++++++++++++++++++++++++ app/src/routes/+layout.svelte | 27 +++++++++++++++++++++++++++ app/src/routes/+layout.ts | 2 +- app/src/routes/+page.svelte | 6 +++++- 7 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 app/src/hooks.server.ts (limited to 'app/src') diff --git a/app/src/app.d.ts b/app/src/app.d.ts index 8f4d638..3e4ed20 100644 --- a/app/src/app.d.ts +++ b/app/src/app.d.ts @@ -2,8 +2,8 @@ // for information about these interfaces // and what to do when importing types declare namespace App { - // interface Locals {} - // interface PageData {} - // interface Error {} - // interface Platform {} + // interface Locals {} + // interface PageData {} + // interface Error {} + // interface Platform {} } diff --git a/app/src/app.html b/app/src/app.html index 0297ac7..4480bed 100644 --- a/app/src/app.html +++ b/app/src/app.html @@ -1,12 +1,12 @@ - + - - - - - %sveltekit.head% - - -
%sveltekit.body%
- + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ diff --git a/app/src/app.postcss b/app/src/app.postcss index 8ef7d35..f3fef83 100644 --- a/app/src/app.postcss +++ b/app/src/app.postcss @@ -5,5 +5,5 @@ html, body { - @apply h-full overflow-hidden; + @apply h-full overflow-hidden; } diff --git a/app/src/hooks.server.ts b/app/src/hooks.server.ts new file mode 100644 index 0000000..163f640 --- /dev/null +++ b/app/src/hooks.server.ts @@ -0,0 +1,35 @@ +import { minify } from 'html-minifier-terser'; +import { building } from '$app/environment'; + +const minification_options = { + collapseBooleanAttributes: true, + collapseWhitespace: true, + conservativeCollapse: true, + decodeEntities: true, + html5: true, + ignoreCustomComments: [/^#/], + minifyCSS: true, + minifyJS: true, + removeAttributeQuotes: true, + removeComments: false, // some hydration code needs comments, so leave them in + removeOptionalTags: true, + removeRedundantAttributes: true, + removeScriptTypeAttributes: true, + removeStyleLinkTypeAttributes: true, + sortAttributes: true, + sortClassName: true +}; + +/** @type {import('@sveltejs/kit').Handle} */ +export async function handle({ event, resolve }) { + let page = ''; + + return resolve(event, { + transformPageChunk: ({ html, done }) => { + page += html; + if (done) { + return building ? minify(page, minification_options) : page; + } + } + }); +} \ No newline at end of file diff --git a/app/src/routes/+layout.svelte b/app/src/routes/+layout.svelte index 3d5c07f..93a41b1 100644 --- a/app/src/routes/+layout.svelte +++ b/app/src/routes/+layout.svelte @@ -1,4 +1,8 @@ + + {@html webManifestLink} + + diff --git a/app/src/routes/+layout.ts b/app/src/routes/+layout.ts index c8cacf0..189f71e 100644 --- a/app/src/routes/+layout.ts +++ b/app/src/routes/+layout.ts @@ -1 +1 @@ -export const prerender = true; \ No newline at end of file +export const prerender = true; diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index 67c0353..7cd11ed 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -1,8 +1,12 @@ + + Coming Soon(TM) + +
-

Welcome to Skeleton.

+

Welcome to a placeholder.

-- cgit v1.2.3