-
-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Labels
Description
We already test this in examples/basic
and we can document this as basic suggestion.
vite-plugin-react/packages/plugin-rsc/examples/basic/vite.config.ts
Lines 125 to 163 in a96a6b2
{ | |
name: 'optimize-chunks', | |
apply: 'build', | |
config() { | |
const resolvePackageSource = (source: string) => | |
normalizePath(fileURLToPath(import.meta.resolve(source))) | |
// TODO: this package entry isn't a public API. | |
const reactServerDom = resolvePackageSource( | |
'@vitejs/plugin-rsc/react/browser', | |
) | |
return { | |
environments: { | |
client: { | |
build: { | |
rollupOptions: { | |
output: { | |
manualChunks: (id) => { | |
// need to use functional form to handle commonjs plugin proxy module | |
// e.g. `(id)?commonjs-es-import` | |
if ( | |
id.includes('node_modules/react/') || | |
id.includes('node_modules/react-dom/') || | |
id.includes(reactServerDom) | |
) { | |
return 'lib-react' | |
} | |
if (id === '\0vite/preload-helper.js') { | |
return 'lib-vite' | |
} | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
} | |
}, |