diff --git a/README.md b/README.md index 41fa155..882f1bf 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,38 @@ -# electron-vite - -

- node - vite +

+

-English | [简体中文](./README.zh-CN.md) +
+

electron-vite

+
+

Next generation Electron build tooling based on Vite

-> Next generation Electron build tooling based on Vite +

+ +license +

---- +

+Documentation | +Getting Started | +create-electron +

+ +

+中文文档 +

+ +
+
+
## Features -- ⚡️Use the same way as [Vite](https://vitejs.dev) -- 🔨Main process, renderer process and preload script source code are built using Vite -- 📃Main process, renderer process and preload script Vite configuration combined into one file -- 📦Preset optimal build configuration -- 🚀HMR for renderer processes +- ⚡️ Inherit all the benefits of Vite and use the same way as [Vite](https://vitejs.dev). +- 📦The main process, renderers and preload scripts are all built with Vite. +- 🛠The main process, renderers and preload scripts Vite configuration combined into one file. +- 💡Pre-configured for Electron, don't worry about configuration. +- 🚀HMR for renderer processes. ## Usage @@ -34,14 +49,35 @@ In a project where `electron-vite` is installed, you can use `electron-vite` bin ```json { "scripts": { - "start": "electron-vite preview", // start electron app to preview production build - "dev": "electron-vite dev", // start dev server and electron app - "prebuild": "electron-vite build" // build for production + "start": "electron-vite preview", + "dev": "electron-vite dev", + "prebuild": "electron-vite build" } } ``` -In order to use the renderer process HMR, you need to use the `environment variables` to determine whether the window browser loads a local html file or a remote URL. +### Configuring + +When running `electron-vite` from the command line, electron-vite will automatically try to resolve a config file named `electron.vite.config.js` inside project root. The most basic config file looks like this: + +```js +// electron.vite.config.js +export default { + main: { + // vite config options + }, + preload: { + // vite config options + }, + renderer: { + // vite config options + } +} +``` + +### Use HMR in Renderer + +In order to use the renderer process HMR, you need to use the `environment variables` to determine whether the window browser loads a local html file or a local URL. ```js function createWindow() { @@ -63,27 +99,7 @@ function createWindow() { } ``` -**Note**: For development, the renderer process `index.html` file needs to reference your script code via `