Skip to content

Electron、vue3、vite2、ant-design-vue2 integration

Notifications You must be signed in to change notification settings

muchen404/electron-vue-vite

 
 

Repository files navigation

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

About

Electron、vue3、vite2、ant-design-vue2 integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 47.5%
  • JavaScript 20.2%
  • Vue 17.1%
  • HTML 13.7%
  • CSS 1.3%
  • Shell 0.2%