vite-plugin-native
Version:
Supports Node/Electron C/C++ native addons
62 lines (47 loc) • 1.69 kB
Markdown
is a bundle solution based on [Webpack](https://github.com/webpack/webpack).
> Thanks [Erick Zhao](https://github.com/erickzhao) for providing inspiration :)
[](https://npmjs.org/package/vite-plugin-native)
[](https://npmjs.org/package/vite-plugin-native)
English | [简体中文](./README.zh-CN.md)
```bash
npm i -D vite-plugin-native
```
```js
import native from 'vite-plugin-native'
export default {
plugins: [
native({
// Enable Webpack
webpack: {},
})
]
}
```
```ts
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.
* @deprecated use `ignore` option instead
*/
natives?: string[] | ((natives: string[]) => string[])
/** Ignore the specified native module. */
ignore?: (name: string) => boolean | undefined
/** Force copy *.node files to dist/node_modules path if Webpack can't bundle native modules correctly. */
forceCopyIfUnbuilt?: true
/** 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)](./README.zh-CN.md
Supports Node/Electron C/C++ native addons. It