mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 10:37:35 +00:00
* perf(dev): serve the renderer with bundled dev mode by default * test(dev): expect bundled renderer dev by default
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { UserConfig } from 'electron-vite'
|
|
|
|
/**
|
|
* Default in dev (opt out with `ORCA_DEV_BUNDLED=0`): Vite's bundled dev mode serves the renderer as
|
|
* bundled chunks instead of thousands of per-module requests, which shortens dev startup and reloads.
|
|
*/
|
|
export function withBundledRendererDev(
|
|
config: UserConfig,
|
|
env: NodeJS.ProcessEnv = process.env
|
|
): UserConfig {
|
|
const renderer = config.renderer
|
|
if (env.ORCA_DEV_BUNDLED === '0' || !renderer || typeof renderer === 'function') {
|
|
return config
|
|
}
|
|
const rollupOptions = renderer.build?.rollupOptions
|
|
const output = Array.isArray(rollupOptions?.output) ? undefined : rollupOptions?.output
|
|
return {
|
|
...config,
|
|
renderer: {
|
|
...renderer,
|
|
experimental: { ...renderer.experimental, bundledDev: true },
|
|
build: {
|
|
...renderer.build,
|
|
rollupOptions: {
|
|
...rollupOptions,
|
|
// Why: chunks shared by the four HTML entries otherwise run before the React Refresh
|
|
// preamble in the entry chunk, and the renderer fails with "can't detect preamble".
|
|
output: { ...output, strictExecutionOrder: true }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|