mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
chore: UPDATE
This commit is contained in:
parent
abd91f809a
commit
c1e43c224c
32
README.md
32
README.md
@ -9,14 +9,34 @@
|
||||
- npm run build
|
||||
|
||||
## Note
|
||||
- Using `Nodejs` `Electron` API in vite and using require to import
|
||||
- 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 `esm2cjs` plugin
|
||||
```ts
|
||||
// import { readFile } from 'fs'
|
||||
// import { ipcRenderer } from 'electron'
|
||||
|
||||
const { readFile } = require('fs')
|
||||
const { ipcRenderer } = require('electron')
|
||||
import { ipcRenderer } from 'electron'
|
||||
import Store from 'electron-store'
|
||||
// Will generate
|
||||
const { ipcRenderer } = require("electron")
|
||||
const Store = require("electron-store")
|
||||
```
|
||||
- It works!
|
||||
|
||||
- 🚀
|
||||
|
||||
- 开发模式下 Electron 相关的 API 需要转换成 commonjs
|
||||
- 并且你只能用 ESM
|
||||
- 为此我写了一个 `esm2cjs` 插件
|
||||
|
||||
## electron-vue-vite-webpack
|
||||
- If you are afraid of stepping on the pit, you can consider using this project
|
||||
[ https://github.com/caoxiemeihao/electron-vue-vite-webpack ]( https://github.com/caoxiemeihao/electron-vue-vite-webpack )
|
||||
The production environment is packaged with 'webpack'
|
||||
|
||||
- 🚀
|
||||
|
||||
- 如果你怕踩坑,可以考虑用这个项目
|
||||
[https://github.com/caoxiemeihao/electron-vue-vite-webpack](https://github.com/caoxiemeihao/electron-vue-vite-webpack)
|
||||
生产环境使用 `webpack` 打包的
|
||||
|
||||
---
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default defineConfig(env => {
|
||||
optimizeDeps: {
|
||||
exclude: [
|
||||
'electron',
|
||||
'electron-store', // optional
|
||||
// 'electron-store', // optional
|
||||
],
|
||||
},
|
||||
build: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user