BREAKING CHANGE: initialized vite + frontend, electron currently broken
tsconfig.json and vite.config.ts makes things difficult to build but we're getting somewhere on it. I'm likely going to change these files and perhaps the layout of the project as it grows, especially for the debugging parts and building parts (e.g ./dist/ and the ts, vite, and node configs) so far, its going well, slow and steady start, the next thing I need to target is fixing to why electron won't load built vite files and figure out how to run electron and vite together perhaps as a means of making debugging / programming easier
This commit is contained in:
commit
73cb54ad4f
10 changed files with 3248 additions and 0 deletions
152
.gitignore
vendored
Normal file
152
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
# From https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Node.gitignore
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
.output
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp directory
|
||||
.temp
|
||||
|
||||
# Sveltekit cache directory
|
||||
.svelte-kit/
|
||||
|
||||
# vitepress build output
|
||||
**/.vitepress/dist
|
||||
|
||||
# vitepress cache directory
|
||||
**/.vitepress/cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# Firebase cache directory
|
||||
.firebase/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores Visual Studio Code versions used for testing Visual Studio Code extensions
|
||||
.vscode-test
|
||||
|
||||
# pnpm
|
||||
.pnpm-store
|
||||
|
||||
# yarn v3
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# Vite files
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
.vite/
|
||||
|
||||
# Astro generated types
|
||||
.astro/
|
||||
|
||||
# Turbo Repo
|
||||
.turbo
|
||||
|
||||
22
eslint.config.js
Normal file
22
eslint.config.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
2905
package-lock.json
generated
Normal file
2905
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
29
package.json
Normal file
29
package.json
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev:render": "vite --mode renderer",
|
||||
"dev:build": "vite build --mode renderer",
|
||||
"dev:electron": "electron src/main/main.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.3.1",
|
||||
"react-dom": "^19.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@types/node": "^24.19.2",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
"@vitejs/plugin-react": "^6.1.2",
|
||||
"electron": "^45.0.0",
|
||||
"eslint": "^10.13.0",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.7",
|
||||
"globals": "^17.13.0",
|
||||
"typescript": "~6.0.3",
|
||||
"typescript-eslint": "^8.71.2",
|
||||
"vite": "^8.3.4"
|
||||
}
|
||||
}
|
||||
20
src/main/main.ts
Normal file
20
src/main/main.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { app, BrowserWindow } from "electron"
|
||||
import { pathToFileURL } from "node:url"
|
||||
import path from "node:path"
|
||||
|
||||
const test = pathToFileURL((path.dirname(".") + "/release/app/dist/renderer/index.html")).href
|
||||
console.log(test)
|
||||
|
||||
const mainWindowInit = () => {
|
||||
const window = new BrowserWindow({
|
||||
width: 1280,
|
||||
height: 720
|
||||
})
|
||||
|
||||
window.loadURL(test)
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
mainWindowInit()
|
||||
})
|
||||
|
||||
18
src/renderer/index.html
Normal file
18
src/renderer/index.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<!-- NOTE: Remember to add an icon for this evetually -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="A sample electron app" />
|
||||
<title>Sample Electron App</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<noscript>Javascript is NOT enabled! Please enable it to ensure functionality</noscript>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/main.tsx"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
11
src/renderer/src/app/index.tsx
Normal file
11
src/renderer/src/app/index.tsx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function App() {
|
||||
return (
|
||||
<>
|
||||
<body>
|
||||
hello this is a new test!
|
||||
</body>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
10
src/renderer/src/main.tsx
Normal file
10
src/renderer/src/main.tsx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { createRoot } from "react-dom/client"
|
||||
import App from "@/src/app"
|
||||
|
||||
const root = document.getElementById("root")
|
||||
|
||||
if (!root) throw new Error("Root element NOT found!")
|
||||
|
||||
createRoot(root).render(
|
||||
<App />
|
||||
)
|
||||
39
tsconfig.json
Normal file
39
tsconfig.json
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"types": ["vite/client", "react", "node"],
|
||||
"allowArbitraryExtensions": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
/* Other */
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
|
||||
"paths": {
|
||||
"@/*": ["./src/renderer/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
42
vite.config.ts
Normal file
42
vite.config.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import path from "node:path"
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
const rootDirectory = import.meta.dirname
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
if (mode === "renderer") {
|
||||
return {
|
||||
root: path.join(rootDirectory, "/src/renderer"),
|
||||
base: "/",
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
// NOTE: Very important to set tsconfigPaths = true
|
||||
// For compatibility with pathing of your web program
|
||||
tsconfigPaths: true
|
||||
},
|
||||
build: {
|
||||
outDir: path.join(rootDirectory, "/release/app/dist/renderer"),
|
||||
emptyOutDir: true,
|
||||
rolldownOptions: {
|
||||
input: path.join(rootDirectory, "/src/renderer/index.html"),
|
||||
//output: { entryFileNames: "release/app/dist/renderer/renderer.js" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
/*
|
||||
return {
|
||||
renderer: {
|
||||
root: path.join(rootDirectory, "src/renderer"),
|
||||
base: "./"
|
||||
}
|
||||
}
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue