mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-02-26 04:40:10 +08:00
feat: use Node.js API in the Renderer-proces
This commit is contained in:
parent
fe52c1f937
commit
d08921d6f6
@ -20,6 +20,7 @@
|
||||
"typescript": "^4.8.4",
|
||||
"vite": "^3.1.4",
|
||||
"vite-electron-plugin": "^0.4.6",
|
||||
"vite-plugin-electron-renderer": "^0.10.1",
|
||||
"vue": "^3.2.40",
|
||||
"vue-tsc": "^0.40.13"
|
||||
},
|
||||
|
10
src/main.ts
10
src/main.ts
@ -1,14 +1,6 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
/**
|
||||
* If you enables use of Node.js API in the Renderer-process
|
||||
* ```
|
||||
* npm i -D vite-plugin-electron-renderer
|
||||
* ```
|
||||
* @see - https://github.com/electron-vite/vite-plugin-electron/tree/main/packages/electron-renderer#electron-renderervite-serve
|
||||
*/
|
||||
// import './samples/node-api'
|
||||
import './samples/node-api'
|
||||
|
||||
createApp(App)
|
||||
.mount('#app')
|
||||
|
@ -3,6 +3,7 @@ import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import electron from 'vite-electron-plugin'
|
||||
import { customStart } from 'vite-electron-plugin/plugin'
|
||||
import renderer from 'vite-plugin-electron-renderer'
|
||||
import pkg from './package.json'
|
||||
|
||||
rmSync('dist-electron', { recursive: true, force: true })
|
||||
@ -21,6 +22,10 @@ export default defineConfig({
|
||||
? [customStart(debounce(() => console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')))]
|
||||
: undefined,
|
||||
}),
|
||||
// Use Node.js API in the Renderer-process
|
||||
renderer({
|
||||
nodeIntegration: true,
|
||||
}),
|
||||
],
|
||||
server: process.env.VSCODE_DEBUG ? (() => {
|
||||
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user