template-electron-vuex-vuetify
Overview
This template should help get you started developing Electron
app using Vue 3
, Vite
, Vuex
and Vuetify
, and friends.
Main Window
Run Setup
# clone the project
git clone https://github.com/governance-foundation/template-electron-vuex-vuetify.git
# enter the project directory
cd template-electron-vuex-vuetify
# install dependency
npm install
# develop
npm run electron:dev
Recommended IDE Setup
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
.vue
Imports in TS
Type Support for TypeScript cannot handle type information for .vue
imports by default, so we replace the tsc
CLI with vue-tsc
for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue
types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:
- Disable the built-in TypeScript Extension
- Run
Extensions: Show Built-in Extensions
from VSCode's command palette - Find
TypeScript and JavaScript Language Features
, right click and selectDisable (Workspace)
- Run
- Reload the VSCode window by running
Developer: Reload Window
from the command palette.
Customize configuration
See Vite Configuration Reference.
Project Setup
npm install
Compile and Hot-Reload for Development
npm run dev
Type-Check, Compile and Minify for Production
npm run build
Vitest
Run Unit Tests withNOTE: this does not work yet, feel free to contribute.
npm run test:unit
Cypress
Run End-to-End Tests withnpm run build
npm run test:e2e # or `npm run test:e2e:ci` for headless testing
ESLint
Lint withnpm run lint
Electron Dev
Run development server and electron UI.
npm run electron:dev
Build Electron Dist
Compile installable Electron packages.
npm run app:build
Add Githooks
npx simple-git-hooks
Customize configuration
- See Configuration Reference.
- Mac category LSApplicationCategoryType
- Update App Icons in
electron/assets
folder. - Update App Details and build config in
package.json
.
Pipelines
Following pipleines exist for compiling code as its commited
- Build Branche (build.yml) - Build and Test all branches and create releases.
Releasing
When you want to create a new release, follow these steps:
- Update the project version
npm verison 2022.03.24
this will update the package.json and relevant commit. - If commit was not created, commit and sign that change (
git commit -s -a -m "chore: release 2022.02.20"
) - Tag and sign your commit (
git tag -s -a 2022.02.20 -m "2022.02.20"
). Make sure your tag name's format is{YYYY}.{MM}.{DD}
. Your workflow will use this tag to detect when to create a release - Push your changes to GitHub (git push && git push --tags)
Pull Request
When committing code please ensure that you add your commits to dedicated feature branch, name your branch feature/#<issue id>-name-of-issue
.
When creating a PR please add default reviewers to your PR. Set title of your PR as #<issue id> Title of issue
.
When interacting with reviews on your PR please resolve conversartions that you have fixed, and re-request reviews after you have pushed updates to your branch.
App Generation
To generate this app from sratch run the following:
Part 1 - Automated
- Install Vue globally -
npm install -g @vue/cli
- Create Vue App
vue create template-electron-vuex-vuetify
- Please pick a preset:
- Manually select features
- Features (All Yes)
- Babel
- TypeScript
- Progressive Web App (PWA) Support
- Router
- Vuex
- CSS Pre-processors
- Linter / Formatter
- Unit Testing
- E2E Testing
- Use class-style component syntax?
- Yes
- Use Babel alongside TypeScript?
- Yes
- Use history mode for router?
- Yes
- Pick a CSS pre-processor:
- Sass/SCSS (with dart-sass)
- Pick a linter / formatter config:
- ESLint + Prettier
- Please pick a preset:
- Pick additional lint features: * Lint on save
- Pick a unit testing solution:
- Jest
- Pick an E2E testing solution: Cypress
- Where do you prefer placing config:
- In dedicated config files
- Pick a unit testing solution:
- Add Vuetify UI framework
vue add vuetify
- use
Default
- use
Part 2 - Manual steps
- Remove Jest, will be replaced by Vitest
- remove test folder
- remove dependencies
npm remove @types/jest jest ts-jest @vue/vue3-jest @vue/cli-plugin-unit-jest babel-jest @vue/cli-plugin-babel
-
Create Vite template for copying Vite config
- create blank vite-vue app
npm create vite@latest my-vue-app -- --template vue
- copy accross folders
cypress
and.vscode
- copy acresss all the conig files
- create blank vite-vue app
-
Add Electron, Vitest and Vite
- add configs
package.json
,vite.config.ts
,electron.js
andelectron/preload.js
follow this Vite + Vue 3 + electron + TypeScript - add dependencies
- add configs
npm install vitest vue-tsc jsdom start-server-and-test @types/jsdom @types/node @vue/tsconfig @rushstack/eslint-patch @vitejs/plugin-vue concurrently cross-env electron electron-builder wait-on @types/electron-devtools-installer vite --save-dev