From 8d981b7184f12d628325cfdd51e1fba1f42a5ce7 Mon Sep 17 00:00:00 2001 From: leejooy96 Date: Thu, 16 Feb 2023 08:38:28 +0900 Subject: [PATCH] docs: update documents --- docs/main-and-renderer-process.md | 20 ++++++++++++++++++-- docs/pre-configured-components.md | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/main-and-renderer-process.md b/docs/main-and-renderer-process.md index 09c6a70..d75f9a2 100644 --- a/docs/main-and-renderer-process.md +++ b/docs/main-and-renderer-process.md @@ -4,6 +4,22 @@ A **Vutron** application is divided into code into a Main process and a Renderer **"Main"** is the code of `src/main` and is mainly the process code handled by Electron. **"Renderer"** is the code of `src/renderer`, mainly for front-end rendering process like Vue. -The script code of Main cannot be referenced in the Renderer or vice versa, and the two processes can communicate using `IPC`. +In general, **NodeJS** scripts cannot be run in the renderer process. Examples include modules that contain APIs used by NodeJS, or native modules of **NodeJS** such as `path` or `net`, `os` or `crypto`. -Please see the article below for more details: https://www.electronjs.org/docs/latest/tutorial/ipc +Preload scripts are run before the renderer is loaded. It creates a bridge to the main process to keep the execution of NodeJS scripts in the renderer area separate and isolated for security reasons. + +For secure script execution, it is recommended that the main process executes the Node scripts, and the renderer receives the execution results via messaging. This can be implemented via **IPC communication**. + +For more information on this, see the following articles: https://www.electronjs.org/docs/latest/tutorial/ipc + +### How to run NodeJS on a renderer + +If you want to skip the security issues and use NodeJS scripts in your renderer, you need to set `nodeIntegration` to `true` in your `vite.config.ts` file. + +```javascript +rendererPlugin({ + nodeIntegration: true +}) +``` + +For more information on this, see the following articles: https://github.com/electron-vite/vite-plugin-electron-renderer diff --git a/docs/pre-configured-components.md b/docs/pre-configured-components.md index 17aa2c8..3401ecf 100644 --- a/docs/pre-configured-components.md +++ b/docs/pre-configured-components.md @@ -1,7 +1,7 @@ # Pre-configured Components - [Vite 4.x.x](https://vitejs.dev) -- [Electron 22.x.x](https://www.electronjs.org) +- [Electron 23.x.x](https://www.electronjs.org) - [Electron Builder 23.x](https://www.electron.build) - [TypeScript 4.x](https://www.typescriptlang.org) - [Vue 3.2.x](https://vuejs.org)