Supports Node/Electron C/C++ native addons. It is a bundle solution based on Webpack.
Thanks Erick Zhao for providing inspiration :)
English | 简体中文
npm i -D vite-plugin-native
import native from 'vite-plugin-native'
export default {
plugins: [
native({
// Enable Webpack
webpack: {},
})
]
}
export interface NativeOptions {
/** @default 'node_natives' */
assetsDir?: string
/** By default native modules are automatically detected if this option is not explicitly configure by the user. */
natives?: string[] | ((natives: string[]) => string[])
/** Enable and configure webpack. */
webpack?: {
config?: (config: Configuration) => Configuration | undefined | Promise<Configuration | undefined>
'node-loader'?: NodeLoaderOptions,
'@vercel/webpack-asset-relocator-loader'?: WebpackAssetRelocatorLoader,
},
}
TODO: Translate into English.
See 👉🏻 工作原理 (How to work)