Files
tibi-svelte-starter/esbuild.config.server.js
T
apairon 4a604bab0b 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.
2026-05-12 15:47:53 +00:00

46 lines
1.7 KiB
JavaScript

const fs = require("fs")
const config = require("./esbuild.config.js")
const svelteConfig = require("./svelte.config")
// Server build must NOT overwrite buildInfo written by the frontend build,
// otherwise the server timestamp is newer → checkBuildVersion triggers spurious reload.
// Only generate if buildInfo.js doesn't exist yet (standalone server build).
if (!fs.existsSync(__dirname + "/api/hooks/lib/buildInfo.js")) {
config.writeBuildInfo()
}
config.writeBuildInfo = null
config.options.sourcemap = true
config.options.minify = false
config.options.platform = "node"
config.options.format = "cjs"
// Keep modern syntax that goja supports natively and downlevel only unsupported features.
config.options.target = "esnext"
config.options.supported = { "async-await": false, "async-generator": false, "dynamic-import": false }
config.options.entryPoints = ["./frontend/src/ssr.ts"]
config.options.outfile = __dirname + "/api/hooks/lib/app.server.js"
// Remove splitting-related options inherited from the frontend build.
delete config.options.outdir
delete config.options.splitting
delete config.options.entryNames
delete config.options.chunkNames
delete config.options.outExtension
config.options.plugins = [
config.sveltePlugin({
compilerOptions: {
generate: "server",
css: "external",
dev: (process.argv?.length > 2 ? process.argv[2] : "build") !== "build",
},
preprocess: svelteConfig.preprocess,
filterWarnings: (warning) => {
// filter out a11y
if (warning.code.match(/^a11y/)) return false
return true
},
}),
config.resolvePlugin,
]
module.exports = config