Go to file
2021-06-30 09:29:04 +08:00
blog chore: UPDATE wx qrcode 2021-06-30 09:29:04 +08:00
screenshot chore: UPDRTE 2021-02-19 14:26:29 +08:00
script chore: delete useless files 2021-05-23 18:06:31 +08:00
src fix: 启动动画卡顿 2021-06-23 11:19:36 +08:00
typings chore: redeclare typings 2021-06-23 10:58:52 +08:00
.env npm run dev:all :) 2020-08-16 20:42:52 +08:00
.gitignore chore: UPDATE 2021-05-30 07:50:29 +08:00
.npmrc chore: .yarnrc -> .npmrc 2021-05-08 17:35:20 +08:00
note.md chore: UPDATE 2021-05-30 08:24:29 +08:00
package.json chore: UPDATE dependencies 2021-06-23 10:34:50 +08:00
README.md chore: Add WX group chat 2021-06-20 19:10:27 +08:00
tsconfig.json chore: redeclare typings 2021-06-23 10:58:52 +08:00
vite.config.ts chore: UPDATE vitejs-plugin-electron 2021-05-23 14:48:01 +08:00
yarn.lock chore: UPDATE dependencies 2021-06-23 10:34:50 +08:00

electron-vue-vite

Electron + Vue3 + Vite2 integration

How and Why

  • Vite is the scaffold of the future

Command

  • npm run dev
  • npm run build

Note

  • In the development environment, we need to transform the Electron related API into commonjs
  • And you can only use ESM
  • So far, I've written an vitejs-plugin-electron plugin

Usage

  • vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import electron from 'vitejs-plugin-electron'

export default defineConfig((env) => ({
  plugins: [
    vue(),
    electron(),
  ],
  // other config...
}))

In "src/render/main.ts" file

// You code
import { ipcRenderer } from 'electron'
import Store from 'electron-store'

// Will be generate in development mode
const { ipcRenderer } = require("electron")
const Store = require("electron-store")
  • It works!

  • 🚀

  • 开发模式下 Electron 相关的 API 需要转换成 commonjs

  • 并且你只能用 ESM

  • 为此我写了一个 vitejs-plugin-electron 插件

electron-vue-vite-webpack



微信讨论


License

MIT License