electron-vite-vue/README.md

50 lines
1.5 KiB
Markdown
Raw Normal View History

2020-08-16 12:49:24 +08:00
# electron-vue-vite
2021-03-30 09:57:22 +08:00
`Electron` + `Vue3` + `Vite2` integration
2020-08-16 20:42:52 +08:00
## How and Why
2021-03-30 09:57:22 +08:00
- `Vite` is the scaffold of the future
2020-08-16 21:00:37 +08:00
2020-10-05 21:48:49 +08:00
## Command
2020-08-17 09:21:07 +08:00
- npm run dev
- npm run build
2020-08-16 21:00:37 +08:00
2021-03-30 09:57:22 +08:00
## Note
2021-05-16 20:28:02 +08:00
- In the development environment, we need to transform the `Electron` related API into commonjs
- And you can only use ESM
2021-05-23 11:13:49 +08:00
- So far, I've written an [vitejs-plugin-electron](https://github.com/caoxiemeihao/vitejs-plugins/tree/main/electron) plugin
2021-03-30 09:57:22 +08:00
```ts
2021-05-16 20:28:02 +08:00
import { ipcRenderer } from 'electron'
import Store from 'electron-store'
// Will generate
const { ipcRenderer } = require("electron")
const Store = require("electron-store")
```
2021-05-16 20:28:02 +08:00
- It works!
- 🚀
- 开发模式下 Electron 相关的 API 需要转换成 commonjs
- 并且你只能用 ESM
2021-05-23 11:13:49 +08:00
- 为此我写了一个 [vitejs-plugin-electron](https://github.com/caoxiemeihao/vitejs-plugins/tree/main/electron) 插件
2021-05-16 20:28:02 +08:00
## electron-vue-vite-webpack
2021-05-27 14:02:07 +08:00
- If you're worried, you can consider using this project<br>
[https://github.com/caoxiemeihao/electron-vue-vite-webpack]( https://github.com/caoxiemeihao/electron-vue-vite-webpack)<br>
The production environment is packaged with 'webpack'
2021-05-16 20:28:02 +08:00
- 🚀
2021-05-27 14:02:07 +08:00
- 如果你怕踩坑,可以考虑用这个项目<br>
[https://github.com/caoxiemeihao/electron-vue-vite-webpack](https://github.com/caoxiemeihao/electron-vue-vite-webpack)<br>
生产环境使用 `webpack` 打包的
2020-09-02 09:19:15 +08:00
2020-08-17 09:21:07 +08:00
---
2020-08-16 21:00:37 +08:00
2021-03-30 09:57:22 +08:00
![](https://raw.githubusercontent.com/caoxiemeihao/electron-vue-vite/main/screenshot/800x600-2.png)
2021-05-08 17:29:38 +08:00
---
## License
[MIT License](https://opensource.org/licenses/MIT)