A Webpack-based pre-bundle solution, mainly used for adapting Node.js and Electron.
English | 简体中文
npm i -D vite-plugin-webpack-prebundle
import prebundle from 'vite-plugin-webpack-prebundle'
export default {
plugins: [
prebundle({
modules: [
'foo',
'bar',
],
})
]
}
export interface PrebundleOptions {
/** An array of module names that need to be pre-bundle. */
modules: string[]
config?: (config: Configuration) => Configuration | undefined | Promise<Configuration | undefined>
}
This is a Pre-Bundle solution designed for Node/Electron Apps, which is consistent with Vite's built-in Dependency Pre-Bundling behavior. The reason for using Webpack is that it's currently the most compatible bundler for Node/Electron Apps.
Pre-Bundle solution | Web | Node/Electron |
---|---|---|
Vite's built-in Dependency Pre-Bundling | ✅ | ❌ |
vite-plugin-webpack-prebundle | ✅ | ✅ |