Heavy Launch / Build Optimizations
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="description" content="Borealis — Workflow Automation Tool" />
|
||||
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||
<link rel="apple-touch-icon" href="/Borealis_Logo.png" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
|
||||
<title>Borealis</title>
|
||||
|
39
Data/Server/WebUI/vite.config.mts
Normal file
39
Data/Server/WebUI/vite.config.mts
Normal file
@ -0,0 +1,39 @@
|
||||
////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/Server/WebUI/vite.config.ts
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
open: true,
|
||||
host: true,
|
||||
strictPort: true,
|
||||
allowedHosts: ['localhost','127.0.0.1','borealis.bunny-lab.io'],
|
||||
proxy: {
|
||||
'/api': 'http://localhost:5000',
|
||||
'/socket.io': { target:'ws://localhost:5000', ws:true }
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: 'build',
|
||||
emptyOutDir: true,
|
||||
chunkSizeWarningLimit: 1000,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// split each npm package into its own chunk
|
||||
manualChunks(id) {
|
||||
if (id.includes('node_modules')) {
|
||||
return id.toString()
|
||||
.split('node_modules/')[1]
|
||||
.split('/')[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
alias: { '@': path.resolve(__dirname, 'src') },
|
||||
extensions: ['.js','.jsx','.ts','.tsx']
|
||||
}
|
||||
});
|
@ -1,33 +0,0 @@
|
||||
////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/Server/WebUI/vite.config.ts
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
open: true,
|
||||
host: true, // <-- allows LAN access and shows LAN IP
|
||||
strictPort: true, // <-- Ensures that the port number never changes (Good for Reverse Proxies)
|
||||
allowedHosts: [
|
||||
'localhost',
|
||||
'127.0.0.1',
|
||||
'borealis.bunny-lab.io'
|
||||
],
|
||||
proxy: {
|
||||
'/api': 'http://localhost:5000',
|
||||
'/socket.io': {
|
||||
target: 'ws://localhost:5000',
|
||||
ws: true
|
||||
}
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: 'build',
|
||||
emptyOutDir: true
|
||||
},
|
||||
resolve: {
|
||||
alias: { '@': path.resolve(__dirname, 'src') },
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
||||
}
|
||||
});
|
@ -4,10 +4,11 @@ import eventlet
|
||||
# Monkey-patch stdlib for cooperative sockets
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from flask import Flask, request, jsonify, Response
|
||||
from flask import Flask, request, jsonify, Response, send_from_directory
|
||||
from flask_socketio import SocketIO, emit
|
||||
|
||||
import time
|
||||
import os # To Read Production ReactJS Server Folder
|
||||
|
||||
# Borealis Python API Endpoints
|
||||
from Python_API_Endpoints.ocr_engines import run_ocr_on_base64
|
||||
@ -15,7 +16,12 @@ from Python_API_Endpoints.ocr_engines import run_ocr_on_base64
|
||||
# ---------------------------------------------
|
||||
# Flask + WebSocket Server Configuration
|
||||
# ---------------------------------------------
|
||||
app = Flask(__name__)
|
||||
app = Flask(
|
||||
__name__,
|
||||
static_folder=os.path.join(os.path.dirname(__file__), '../web-interface/build'),
|
||||
static_url_path=''
|
||||
)
|
||||
|
||||
socketio = SocketIO(
|
||||
app,
|
||||
cors_allowed_origins="*",
|
||||
@ -26,6 +32,20 @@ socketio = SocketIO(
|
||||
}
|
||||
)
|
||||
|
||||
# ---------------------------------------------
|
||||
# Serve ReactJS Production Vite Build from dist/
|
||||
# ---------------------------------------------
|
||||
@app.route('/', defaults={'path': ''})
|
||||
@app.route('/<path:path>')
|
||||
def serve_dist(path):
|
||||
full_path = os.path.join(app.static_folder, path)
|
||||
if path and os.path.isfile(full_path):
|
||||
return send_from_directory(app.static_folder, path)
|
||||
else:
|
||||
# SPA entry point
|
||||
return send_from_directory(app.static_folder, 'index.html')
|
||||
|
||||
|
||||
# ---------------------------------------------
|
||||
# Health Check Endpoint
|
||||
# ---------------------------------------------
|
||||
@ -203,7 +223,7 @@ def receive_screenshot(data):
|
||||
|
||||
@socketio.on("disconnect")
|
||||
def on_disconnect():
|
||||
print("[WS] Agent disconnected")
|
||||
print("[WebSocket] Connection Disconnected")
|
||||
|
||||
# ---------------------------------------------
|
||||
# Server Launch
|
||||
|
Reference in New Issue
Block a user