mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-31 20:16:36 +08:00
docs: Use SerialPort, SQLite3 or other node-native addons in Main-process
This commit is contained in:
parent
76c4b446b6
commit
453f7e3be0
27
README.md
27
README.md
@ -95,6 +95,33 @@ Once `dev` or `build` npm-script executed will be generate named `dist` folder.
|
||||
console.log('ipcRenderer', window.ipcRenderer)
|
||||
```
|
||||
|
||||
## Use SerialPort, SQLite3 or other node-native addons in Main-process
|
||||
|
||||
Main-process, Preload-script are also built with Vite, and they are just built as [build.lib](https://vitejs.dev/config/#build-lib).
|
||||
So they just need to configure Rollup.
|
||||
|
||||
**Click to view more** 👉 [scripts/vite.config.mjs](https://github.com/caoxiemeihao/electron-vue-vite/blob/main/scripts/vite.config.mjs)
|
||||
|
||||
```js
|
||||
export default {
|
||||
build: {
|
||||
// built lib for Main-process, Preload-script
|
||||
lib: {
|
||||
entry: 'index.ts',
|
||||
formats: ['cjs'],
|
||||
fileName: () => '[name].js',
|
||||
},
|
||||
rollupOptions: {
|
||||
// configuration here
|
||||
external: [
|
||||
'serialport',
|
||||
'sqlite3',
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## `dependencies` vs `devDependencies`
|
||||
|
||||
- First, you need to know if deps(npm package) are still needed after packaged.
|
||||
|
Loading…
x
Reference in New Issue
Block a user