banner
MoLeft

MoLeft's xLog

Hey! Welcome to my Xlog. The no blackchains on https://www.moleft.cn
github
email

How to gracefully create an Electron + Vue3 + Vite project

Incorrect Example#

First, create a Vite project

yarn create vite

Then add Electron dependencies

yarn add --dev electron concurrently cross-env electron-builder wait-on

After that, there will be endless errors.

Correct Example#

yarn create @quick-start/electron

There will be several options in the middle.

? Add TypeScript? » No / Yes   
Do you want to use TypeScript? If you prefer TypeScript, choose Yes.
? Add Electron updater plugin? » No / Yes 
Do you want to add the Electron updater plugin? Choose Yes.
? Enable Electron download mirror proxy? » No / Yes
Do you want to enable the Electron download mirror proxy? In the Chinese network environment, it is strongly recommended to choose Yes.

Of course, in the Chinese environment, you can set the Electron mirror through the configuration file.

touch .npmrc && echo "electron.mirror=https://npm.taobao.org/mirrors/electron/" > .npmrc

After creating it, just run yarn to install the dependencies and yarn dev to run it.

Conclusion#

It was really a roller coaster to create this project, and in the end, it was concluded that using @quick-start/electron to create the project is indeed fast.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.