✨ refactor: streamline SSR setup and remove Babel configuration
- Updated import path for app.server module in SSR hook. - Removed babel.config.server.json as Babel is no longer needed for async/await transformation. - Adjusted esbuild configuration to target ESNext and modified output paths. - Enhanced App.svelte to handle initial content loading during SSR. - Updated SSR script to load messages synchronously before rendering. - Simplified build:server script in package.json by removing Babel step.
This commit is contained in:
@@ -213,8 +213,21 @@
|
||||
loading = false
|
||||
}
|
||||
|
||||
if (typeof window === "undefined") {
|
||||
;(() => {
|
||||
const initialPath = url.split("?")[0] || "/"
|
||||
const initialLang = extractLanguageFromPath(initialPath) || DEFAULT_LANGUAGE
|
||||
const initialRoutePath = stripLanguageFromPath(initialPath) || "/"
|
||||
loadContent(initialLang, initialRoutePath)
|
||||
})()
|
||||
}
|
||||
|
||||
// Re-load content when path or language changes
|
||||
$effect(() => {
|
||||
if (typeof window === "undefined") {
|
||||
return
|
||||
}
|
||||
|
||||
const lang = $currentLanguage
|
||||
const routePath = stripLanguageFromPath($location.path)
|
||||
loadContent(lang, routePath || "/")
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import deLocale from "./lib/i18n/locales/de.json"
|
||||
import enLocale from "./lib/i18n/locales/en.json"
|
||||
import App from "./App.svelte"
|
||||
|
||||
// SSR: load messages synchronously (Babel transforms import → require)
|
||||
// SSR: load messages synchronously before rendering.
|
||||
addMessages("de", deLocale)
|
||||
addMessages("en", enLocale)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user