A Vite plugin that simplifies dual compilation for SSR (Server-Side Rendering) and CSR (Client-Side Rendering) in a single Vite project. Version 1.0.0 supports Vite ^4||^5||^6. It allows building both server and client entry points simultaneously, streamlining workflows for modern SPAs requiring SSR. Notably, it provides separate output directories for server (dist/) and client (dist/public/) assets, with configurable server build options and external dependencies. Written in TypeScript, it offers type safety and minimal setup compared to manual dual-build configurations.
npm install vite-plugin-builderVerified import paths — ran on the pinned version, not inferred.
Configures Vite with the builder plugin: sets server entry, client entry, and custom build defines for SSR/CSR dual compilation.
Do not set 'outDir' in your Vite config; allow the plugin to manage output directories automatically.
Use { main: 'index.html' } instead of just 'index.html'.Set external: ['express', 'react'] for fine-grained control, or avoid setting it to keep default behavior.
Always return the modified viteConfig object from serverBuild.
Upgrade Vite to version 4 or later.
Upgrade Vite to version >=4: npm install vite@latest
Change import statement to: import builder from 'vite-plugin-builder'
Run npm install vite-plugin-builder --save-dev or yarn add vite-plugin-builder --dev, and ensure import path is correct.
Wrap value in an object: clientEntry: { main: 'index.html' }