Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caoxiemeihao/electron-forge-vite
For test "electron-forge" Vite template.
https://github.com/caoxiemeihao/electron-forge-vite
Last synced: 16 days ago
JSON representation
For test "electron-forge" Vite template.
- Host: GitHub
- URL: https://github.com/caoxiemeihao/electron-forge-vite
- Owner: caoxiemeihao
- License: mit
- Created: 2022-11-17T01:32:32.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-26T10:01:49.000Z (7 months ago)
- Last Synced: 2024-05-02T05:08:18.061Z (6 months ago)
- Language: TypeScript
- Size: 25.1 MB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
> **Since [Electron Forge v6.1.1](https://github.com/electron/forge/releases/tag/v6.1.1) started supporting Vite.**
```tree
├─┬ plugin
│ │
│ ├─┬ src
│ │ ├── util/
│ │ └── VitePlugin.ts `electron-forge-plugin-vite`
│ │
│ ├─┬ src-migration
│ │ └── index.ts `electron-forge-plugin-vite/migration`
│ │
│ └─┬ src-plugin
│ └── index.ts `electron-forge-plugin-vite/plugin`
│
```---
# electron-forge-plugin-vite
For test `electron-forge` Vite template.
> 🚨 This is just a test version of the official plugin `@electron-forge/plugin-vite` and is only intended as a test for the development phase.
## Quick Setup
```sh
# npm
npm i -g electron-forge-template-vite-typescript
npm create electron-app my-vite-app --template=vite-typescript# yarn
yarn global add electron-forge-template-vite-typescript
yarn create electron-app my-vite-app --template=vite-typescript
```## 🔥 Hot restart
```js
// vite.main.config.mjs - For Electron Main
// vite.preload.config.mjs - For Preload Scriptsimport { defineConfig } from 'vite';
import { restart } from 'electron-forge-plugin-vite/plugin';// https://vitejs.dev/config
export default defineConfig({
plugins: [restart()],
});
```## Migration
Migrate to `v7.3.0+` version.
> Why not the Vite plugin? Because dynamically inserting new plugins into the `vite.config.ts` in the plugin does not work!
---
#### `vite.main.config.ts`
```diff
import { defineConfig } from 'vite';
+ import { forgeViteConfig } from 'electron-forge-plugin-vite/migration';// https://vitejs.dev/config
- export default defineConfig({
+ export default defineConfig(forgeViteConfig.main({
resolve: {
// Some libs that can run in both Web and Node.js, such as `axios`, we need to tell Vite to build them in Node.js.
browserField: false,
conditions: ['node'],
mainFields: ['module', 'jsnext:main', 'jsnext'],
},
- });
+ }));
```#### `vite.renderer.config.ts`
```diff
import { defineConfig } from 'vite';
+ import { forgeViteConfig } from 'electron-forge-plugin-vite/migration';// https://vitejs.dev/config
- export default defineConfig({});
+ export default defineConfig(forgeViteConfig.renderer({}));
```---
#### `vite.preload.config.ts`
```diff
import { defineConfig } from 'vite';
+ import { forgeViteConfig } from 'electron-forge-plugin-vite/migration';// https://vitejs.dev/config
- export default defineConfig({});
+ export default defineConfig(forgeViteConfig.preload({}));
```