diff --git a/coldspa/vite/ssr-server.js b/coldspa/vite/ssr-server.js index f53fd8c..346a070 100755 --- a/coldspa/vite/ssr-server.js +++ b/coldspa/vite/ssr-server.js @@ -25,6 +25,7 @@ // // Flags: // --prod switches to prod mode +// --force passes Vite's dependency optimizer force option in dev import { createServer as createHttpServer } from 'http'; import { fileURLToPath, pathToFileURL } from 'url'; @@ -34,6 +35,8 @@ if (process.argv.includes('--prod')) { process.env.NODE_ENV = 'production'; } +const FORCE_OPTIMIZE_DEPS = process.argv.includes('--force'); + const __dirname = dirname(fileURLToPath(import.meta.url)); const PROJECT_ROOT = resolve(process.cwd()); const PORT = Number(process.env.COLDSPA_SSR_PORT || 5174); @@ -73,6 +76,7 @@ async function getRenderer(framework) { viteDevServer = await createServer({ root: PROJECT_ROOT, server: { middlewareMode: true }, + optimizeDeps: FORCE_OPTIMIZE_DEPS ? { force: true } : undefined, appType: 'custom' }); } diff --git a/docs/getting-started.md b/docs/getting-started.md index aba2f4a..d671e10 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -115,6 +115,8 @@ The Coldspa plugin handles client-entry shims, manifest output, and dev-server h `coldspa-ssr` is the SSR sidecar binary shipped in the npm package. Keeping it behind an `ssr` script lets `coldspa.Bootstrap` start the sidecar automatically with `npm run ssr`. +If Vite's dependency optimizer cache needs to be rebuilt during development, run the sidecar with `coldspa-ssr --force` or `npm run ssr -- --force`. + ## 6. Configure runtime URLs (optional) For local single-host dev, the defaults are fine. Otherwise create a `coldspa.config.json` at the webroot: