diff --git a/build/configure/src/web.rs b/build/configure/src/web.rs index c21695908..fe464c0e3 100644 --- a/build/configure/src/web.rs +++ b/build/configure/src/web.rs @@ -184,11 +184,16 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> { let group = format!("ts:{name}"); let deps = inputs![deps, glob!(format!("ts/{name}/**"))]; let extra_exts = if html { &["css", "html"][..] } else { &["css"] }; + let entrypoint = if html { + format!("ts/routes/{name}/index.ts") + } else { + format!("ts/{name}/index.ts") + }; build.add_action( &group, EsbuildScript { script: inputs!["ts/bundle_svelte.mjs"], - entrypoint: inputs![format!("ts/{name}/index.ts")], + entrypoint: inputs![entrypoint], output_stem: &format!("ts/{name}/{name}"), deps: deps.clone(), extra_exts, @@ -212,6 +217,16 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> { ":sveltekit", ], )?; + build_page( + "congrats", + true, + inputs![ + // + ":ts:lib", + ":ts:components", + ":sass", + ], + )?; Ok(()) } diff --git a/ts/routes/congrats/congrats-base.scss b/ts/routes/congrats/congrats-base.scss index 064256027..319c1f415 100644 --- a/ts/routes/congrats/congrats-base.scss +++ b/ts/routes/congrats/congrats-base.scss @@ -1,5 +1,5 @@ -@use "../lib/sass/root-vars"; -@import "../lib/sass/base"; +@use "../../lib/sass/root-vars"; +@import "../../lib/sass/base"; @import "bootstrap/scss/containers"; diff --git a/ts/routes/congrats/index.ts b/ts/routes/congrats/index.ts index 52fc74a3d..995b82c8f 100644 --- a/ts/routes/congrats/index.ts +++ b/ts/routes/congrats/index.ts @@ -1,29 +1,34 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +// +// This old non-Sveltekit entrypoint has been preserved for AnkiWeb compatibility, +// and can't yet be removed. AnkiWeb loads the generated .js file into an existing +// page, and mounts into a div with 'id=congrats'. Unlike the desktop, it does not +// auto-refresh (to reduce the load on AnkiWeb). import "./congrats-base.scss"; import { congratsInfo } from "@generated/backend"; import { ModuleName, setupI18n } from "@tslib/i18n"; import { checkNightMode } from "@tslib/nightmode"; +import { mount } from "svelte"; import CongratsPage from "./CongratsPage.svelte"; const i18n = setupI18n({ modules: [ModuleName.SCHEDULING] }); -export async function setupCongrats(): Promise { +export async function setupCongrats(): Promise { checkNightMode(); await i18n; const customMountPoint = document.getElementById("congrats"); const info = await congratsInfo({}); - const page = new CongratsPage({ - // use #congrats if it exists, otherwise entire body - target: customMountPoint ?? document.body, - props: { info, refreshPeriodically: !customMountPoint }, - }); - - return page; + const props = { info, refreshPeriodically: false }; + mount( + CongratsPage, // use #congrats if it exists, otherwise entire body + { target: customMountPoint ?? document.body, props }, + ); + return; } setupCongrats();