mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 11:05:05 +03:00
Start the Electron version
This commit is contained in:
+2
-1
@@ -379,4 +379,5 @@ pyrightconfig.json
|
||||
data
|
||||
.vite
|
||||
*.db
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
dist-electron
|
||||
Vendored
+18
-2
@@ -15,8 +15,24 @@
|
||||
"panel": "shared"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
"kind": "build"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run (Electron)",
|
||||
"type": "shell",
|
||||
"command": "npm run dev:electron",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { app, BrowserWindow } from 'electron';
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const win = new BrowserWindow({
|
||||
title: 'Main window',
|
||||
})
|
||||
|
||||
// You can use `process.env.VITE_DEV_SERVER_URL` when the vite command is called `serve`
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
win.loadURL(process.env.VITE_DEV_SERVER_URL)
|
||||
} else {
|
||||
// Load your file
|
||||
win.loadFile('dist/index.html');
|
||||
}
|
||||
});
|
||||
+35
-18
@@ -1,22 +1,39 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { createHtmlPlugin } from 'vite-plugin-html'
|
||||
import autoprefixer from 'autoprefixer'
|
||||
import { defineConfig, PluginOption } from 'vite';
|
||||
import { createHtmlPlugin } from 'vite-plugin-html';
|
||||
import autoprefixer from 'autoprefixer';
|
||||
import electron from 'vite-plugin-electron/simple';
|
||||
|
||||
const plugins: PluginOption[] = [
|
||||
createHtmlPlugin({
|
||||
minify: {
|
||||
collapseWhitespace: true,
|
||||
removeComments: true,
|
||||
removeRedundantAttributes: true,
|
||||
removeScriptTypeAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
useShortDoctype: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
if (process.env.VITE_ELECTRON) {
|
||||
plugins.push(
|
||||
electron({
|
||||
main: {
|
||||
entry: "electron/main.ts",
|
||||
},
|
||||
preload: {
|
||||
input: "frontend/electron/preload.ts"
|
||||
},
|
||||
renderer: {},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
createHtmlPlugin({
|
||||
minify: {
|
||||
collapseWhitespace: true,
|
||||
removeComments: true,
|
||||
removeRedundantAttributes: true,
|
||||
removeScriptTypeAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
useShortDoctype: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true
|
||||
}
|
||||
})
|
||||
],
|
||||
plugins: plugins,
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 8301,
|
||||
@@ -50,4 +67,4 @@ export default defineConfig({
|
||||
cssMinify: true,
|
||||
assetsInlineLimit: 0
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -3,6 +3,7 @@
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"main": "frontend/dist-electron/main.js",
|
||||
"scripts": {
|
||||
"backend:run": "cd backend && dotenv -e ../deployment/.env -- ../.venv/bin/fastapi dev --port 8300 main.py",
|
||||
"backend:dependencies": "python3 -m venv .venv && ./.venv/bin/pip3 install -r backend/requirements.txt",
|
||||
@@ -10,10 +11,12 @@
|
||||
"backend:clean": "rm -rf backend/data",
|
||||
"frontend:dev": "vite frontend",
|
||||
"frontend:build": "tsc --project frontend && vite build frontend",
|
||||
"frontend:electron:dev": "VITE_ELECTRON=true npm run frontend:dev",
|
||||
"frontend:preview": "vite preview frontend",
|
||||
"frontend:dependencies": "npm install --ignore-scripts",
|
||||
"frontend:clean": "rm -rf frontend/dist",
|
||||
"dev": "concurrently 'npm run frontend:dev' 'npm run backend:run'",
|
||||
"dev:electron": "concurrently 'npm run frontend:electron:dev' 'npm run backend:run'",
|
||||
"build": "npm run frontend:build",
|
||||
"preview": "cd deployment && docker compose up --build --watch",
|
||||
"preview:clean": "cd deployment && docker compose down -v",
|
||||
@@ -23,12 +26,15 @@
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.21",
|
||||
"concurrently": "^9.2.0",
|
||||
"electron": "^37.3.1",
|
||||
"dotenv-cli": "^10.0.0",
|
||||
"postcss": "^8.5.6",
|
||||
"sass-embedded": "^1.90.0",
|
||||
"terser": "^5.43.1",
|
||||
"typescript": "~5.9.2",
|
||||
"vite": "^7.1.2",
|
||||
"vite-plugin-electron": "^0.29.0",
|
||||
"vite-plugin-electron-renderer": "^0.14.6",
|
||||
"vite-plugin-html": "^3.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user