Skip to content

Commit 557f854

Browse files
committed
Init
0 parents  commit 557f854

25 files changed

+737
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = false
9+
insert_final_newline = false

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
3+
node_modules
4+
5+
dist
6+
dist-electron
7+
release

.vscode/launch.json

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"compounds": [
7+
{
8+
"name": "Run",
9+
"configurations": ["Main"],
10+
"presentation": {
11+
"hidden": false,
12+
"group": "",
13+
"order": 1
14+
},
15+
"stopAll": true
16+
},
17+
{
18+
"name": "Debug",
19+
"configurations": ["Main Debug", "Renderer Debug"],
20+
"presentation": {
21+
"hidden": false,
22+
"group": "",
23+
"order": 2
24+
},
25+
"stopAll": true
26+
},
27+
{
28+
"name": "Breakpoints",
29+
"configurations": ["Main Breakpoints","Renderer Breakpoints"],
30+
"presentation": {
31+
"hidden": false,
32+
"group": "",
33+
"order": 3
34+
},
35+
"stopAll": true
36+
}
37+
],
38+
"configurations": [
39+
{
40+
"name": "Main",
41+
"type": "node",
42+
"request": "launch",
43+
"runtimeExecutable": "yarn",
44+
"runtimeArgs": ["run", "dev"],
45+
"presentation": { "hidden": true }
46+
},
47+
{
48+
"name": "Main Debug",
49+
"type": "node",
50+
"request": "launch",
51+
"runtimeExecutable": "yarn",
52+
"runtimeArgs": ["run", "dev"],
53+
"env": {
54+
"DEBUG": "true"
55+
},
56+
"presentation": { "hidden": true }
57+
},
58+
{
59+
"name": "Main Breakpoints",
60+
"type": "node",
61+
"request": "launch",
62+
"runtimeExecutable": "yarn",
63+
"runtimeArgs": ["run", "dev"],
64+
"env": {
65+
"DEBUG": "true",
66+
"DEBUG_SOURCEMAPS": "true"
67+
},
68+
"presentation": { "hidden": true }
69+
},
70+
{
71+
"name": "Renderer Debug",
72+
"port": 9229,
73+
"request": "attach",
74+
"type": "chrome",
75+
"timeout": 15000,
76+
"skipFiles": [
77+
"<node_internals>/**",
78+
"${workspaceRoot}/node_modules/**",
79+
"${workspaceRoot}/dist-electron/**",
80+
"http://127.0.0.1:5173/**"
81+
],
82+
"presentation": { "hidden": true }
83+
},
84+
{
85+
"name": "Renderer Breakpoints",
86+
"port": 9229,
87+
"request": "attach",
88+
"type": "chrome",
89+
"timeout": 15000,
90+
"skipFiles": [
91+
"<node_internals>/**",
92+
"${workspaceRoot}/node_modules/**",
93+
"${workspaceRoot}/dist-electron/**",
94+
"http://127.0.0.1:5173/**"
95+
],
96+
"presentation": { "hidden": true }
97+
}
98+
]
99+
}

.vscode/settings.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"files.autoSave": "onWindowChange",
3+
"files.autoSaveWorkspaceFilesOnly": true,
4+
"errorLens.followCursor": "allLinesExceptActive",
5+
"errorLens.enabledDiagnosticLevels": [
6+
"error"
7+
],
8+
"errorLens.messageBackgroundMode": "message",
9+
"eslint.lintTask.enable": true,
10+
"files.exclude": {
11+
},
12+
"typescript.tsdk": "node_modules\\typescript\\lib",
13+
"todo-tree.general.rootFolder": "${workspaceFolder}/src",
14+
"typescript.preferences.preferTypeOnlyAutoImports": true
15+
}

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 n-gist
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Template for Vite + Electron + React + TypeScript projects
2+
3+
### Install
4+
5+
```sh
6+
yarn install
7+
```
8+
9+
### Run
10+
11+
```sh
12+
yarn dev
13+
```
14+
15+
### VS Code launch configurations
16+
Run: main process debug console
17+
Debug: main and renderer processes debug consoles
18+
Breakpoints: generate sourcemaps for breakpoints to work
19+
20+
### Build
21+
22+
```sh
23+
yarn build
24+
```

electron-builder.json5

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// @see - https://www.electron.build/configuration/configuration
2+
{
3+
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
4+
"appId": "YourAppID",
5+
"asar": true,
6+
"productName": "gist-vite-electron-react",
7+
"directories": {
8+
"output": "release/${version}"
9+
},
10+
"files": [
11+
"dist",
12+
"dist-electron"
13+
],
14+
"mac": {
15+
"target": [
16+
"dmg"
17+
],
18+
"artifactName": "${productName}-Mac-${version}-Installer.${ext}"
19+
},
20+
"win": {
21+
"target": [
22+
{
23+
"target": "nsis",
24+
"arch": [
25+
"x64"
26+
]
27+
}
28+
],
29+
"artifactName": "${productName}-Windows-${version}-Setup.${ext}"
30+
},
31+
"nsis": {
32+
"oneClick": false,
33+
"perMachine": false,
34+
"allowToChangeInstallationDirectory": true,
35+
"deleteAppDataOnUninstall": false
36+
},
37+
"linux": {
38+
"target": [
39+
"AppImage"
40+
],
41+
"artifactName": "${productName}-Linux-${version}.${ext}"
42+
}
43+
}

eslint.config.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2+
/* eslint-disable @typescript-eslint/no-unsafe-call */
3+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
4+
import { FlatCompat } from '@eslint/eslintrc'
5+
import path from 'path'
6+
import { fileURLToPath } from 'url'
7+
import eslintjs from '@eslint/js'
8+
9+
const __filename = fileURLToPath(import.meta.url)
10+
const __dirname = path.dirname(__filename)
11+
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname
14+
})
15+
16+
export default [
17+
eslintjs.configs.recommended,
18+
...compat.extends(
19+
'plugin:@typescript-eslint/recommended-type-checked',
20+
'plugin:@typescript-eslint/stylistic-type-checked',
21+
// 'plugin:react/recommended', // throws error in ESLint, waiting for fix
22+
'plugin:react/jsx-runtime'
23+
),
24+
...compat.config({
25+
root: true,
26+
env: { browser: true, es2020: true },
27+
plugins: [
28+
'react-refresh',
29+
'@stylistic/js'
30+
],
31+
ignorePatterns: [
32+
'/dist/',
33+
'/dist-electron/',
34+
'/release/'
35+
],
36+
parser: '@typescript-eslint/parser',
37+
parserOptions: {
38+
project: './tsconfig.json',
39+
tsconfigRootDir: __dirname
40+
},
41+
rules: {
42+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true } ],
43+
'@stylistic/js/indent': ['warn', 4, { 'SwitchCase': 1 }],
44+
'@stylistic/js/quotes': ['warn', 'single'],
45+
'@stylistic/js/semi': ['warn', 'never'],
46+
'no-empty': ['warn'],
47+
'@typescript-eslint/no-empty-function': ['warn'],
48+
'@typescript-eslint/no-unused-vars': ['warn']
49+
},
50+
settings: {
51+
'react': {
52+
'version': 'detect'
53+
}
54+
}
55+
})
56+
]

index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title></title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/renderer/main.tsx"></script>
12+
</body>
13+
</html>

package.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "gist-vite-electron-react",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"private": true,
6+
"type": "module",
7+
"main": "dist-electron/main.js",
8+
"scripts": {
9+
"dev": "vite",
10+
"build": "tsc && vite build && electron-builder",
11+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
12+
"preview": "vite preview",
13+
"eslintconfig": "eslint --inspect-config"
14+
},
15+
"dependencies": {},
16+
"devDependencies": {
17+
"@eslint/eslintrc": "^3.0.2",
18+
"@stylistic/eslint-plugin-js": "^2.1.0",
19+
"@types/react": "^18.3.2",
20+
"@types/react-dom": "^18.2.21",
21+
"@typescript-eslint/eslint-plugin": "^7.9.0",
22+
"@typescript-eslint/parser": "^7.9.0",
23+
"@vitejs/plugin-react": "^4.2.1",
24+
"electron": "^30.0.6",
25+
"electron-builder": "^24.13.3",
26+
"eslint": "^9.2.0",
27+
"eslint-plugin-react": "^7.34.1",
28+
"eslint-plugin-react-hooks": "^4.6.0",
29+
"eslint-plugin-react-refresh": "^0.4.7",
30+
"react": "^18.2.0",
31+
"react-dom": "^18.2.0",
32+
"typescript": "^5.2.2",
33+
"vite": "^5.1.6",
34+
"vite-plugin-electron": "^0.28.6",
35+
"vite-plugin-electron-renderer": "^0.14.5"
36+
}
37+
}

src/main/electron-env.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference types="vite-plugin-electron/electron-env" />
2+
3+
declare namespace NodeJS {
4+
interface ProcessEnv {
5+
APP_ROOT: string
6+
APP_ASSETS: string
7+
}
8+
}
9+
10+
interface Window {
11+
ipcRenderer: import('electron').IpcRenderer
12+
}

0 commit comments

Comments
 (0)