diff --git a/.gitignore b/.gitignore index c51a0f0..5a5ed98 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules /build build build_gz +dist /.svelte-kit /package .env @@ -10,3 +11,4 @@ build_gz !.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* +yarn-error.log diff --git a/.prettierignore b/.prettierignore index 3897265..297772e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -6,6 +6,9 @@ node_modules .env .env.* !.env.example +dist/ +build_gz + # Ignore files for PNPM, NPM and YARN pnpm-lock.yaml diff --git a/gzip_build.py b/gzip_build.py index 029de61..f583c63 100644 --- a/gzip_build.py +++ b/gzip_build.py @@ -22,8 +22,7 @@ def process_directory(input_dir, output_dir): gzip_file(input_file_path, output_file_path) print(f'Compressed: {input_file_path} -> {output_file_path}') -# Replace 'input_directory' and 'output_directory' with your actual input and output directories -input_directory = 'build' +input_directory = 'dist' output_directory = 'build_gz' process_directory(input_directory, output_directory) \ No newline at end of file diff --git a/src/lib/style/app.scss b/src/lib/style/app.scss index 91af087..8b4a44d 100644 --- a/src/lib/style/app.scss +++ b/src/lib/style/app.scss @@ -1,15 +1,8 @@ -// @use "../node_modules/@fontsource/antonio/scss/mixins" as Antonio; -// $directory: "../node_modules/@fontsource/ubuntu"; -// @use "../node_modules/@fontsource/ubuntu/scss/mixins" as Ubuntu; - - -// @import "../node_modules/bootstrap/scss/bootstrap"; - @import "../node_modules/bootstrap/scss/functions"; @import "../node_modules/bootstrap/scss/variables"; @import "../node_modules/bootstrap/scss/variables-dark"; -@import "@fontsource/antonio/latin-400.css"; +//@import "@fontsource/antonio/latin-400.css"; @import "@fontsource/ubuntu/latin-400.css"; @import "@fontsource/oswald/latin-400.css"; @@ -100,6 +93,7 @@ nav { } text-align: center; + color: #fff; } } diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index f2db9f8..3ba2108 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -13,4 +13,6 @@ export const load: LayoutLoad = async () => { await waitLocale() } -export const prerender = true; \ No newline at end of file +export const prerender = true; +export const ssr = false; +export const csr = true; \ No newline at end of file diff --git a/src/routes/Status.svelte b/src/routes/Status.svelte index d02f794..326e192 100644 --- a/src/routes/Status.svelte +++ b/src/routes/Status.svelte @@ -93,7 +93,7 @@
{#if $status.data} - Screen cycle: {#if $status.timerRunning}⏵ running{:else}⏸ stopped{/if} + Screen cycle: {#if $status.timerRunning}⏵ running{:else}⏸ stopped{/if} {/if} {/if}
diff --git a/svelte.config.js b/svelte.config.js index 85bfa7a..468ccd1 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -8,7 +8,13 @@ const config = { preprocess: vitePreprocess({ }), - +build: { + rollupOptions: { + output: { + assetFilenames: '[hash]' + } + } +}, kit: { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported or you settled on a specific environment, switch out the adapter. @@ -16,12 +22,14 @@ const config = { adapter: adapter({ // default options are shown. On some platforms // these options are set automatically — see below - pages: 'build', - assets: 'build', - fallback: undefined, + pages: 'dist', + assets: 'dist', + fallback: "bundle.html", precompress: false, strict: true - }) + }), + appDir: "build", + // inlineStyleThreshold: 9999999999 } }; diff --git a/vite.config.ts b/vite.config.ts index eda1156..ea53800 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,9 +1,62 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; +import * as fs from 'fs' +import * as path from 'path' + +const doRewrap = ({ cssClass }) => { + try { + if (fs.existsSync(path.resolve(__dirname, 'dist/bundle.js'))) { + return + } + } catch(e) {} + console.log("\nStart re-wrapping...") + fs.readFile(path.resolve(__dirname, 'dist/bundle.html'), 'utf8', function(err, data){ + if (!data) { + console.log(`[Error]: No bundle.html generated, check svelte.config.js -> config.kit.adapter -> fallback: "bundle.html"`) + return + } + let matchData = data.match(/(?<=]*>)([\s\S]*?)(?=<\/script>)/gm) + if (matchData) { + let cleanData = matchData[0].trim() + .replace(`document.querySelector('[data-sveltekit-hydrate="45h"]').parentNode`, `document.querySelector(".${cssClass}")`) + fs.writeFile(path.resolve(__dirname, 'dist/bundle.js'), cleanData, (err) => { + if (err) + console.log(err) + else { + try { + fs.rename(path.resolve(__dirname,'dist/index.page'), path.resolve(__dirname, 'dist/index.html'), (err) => { }) + } catch (e) { } + try { + fs.unlinkSync(path.resolve(__dirname, 'dist/bundle.html')) + } catch (e) { } + console.log("Finished: bundle.js + index.html have been regenerated.\n") + } + }) + } else + console.log(`[Error]: No proper