mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-13 09:36:05 +00:00
Two issues from running login.html against no Go backend:
1. Dark mode toggled the body class but didn't actually re-theme any
AD-Vue components. The legacy panel relied on custom.min.css which
we haven't ported. AD-Vue 4 ships its own dark algorithm — wrap
LoginPage in <a-config-provider :theme="{ algorithm }"> driven by
our useTheme state, and AD-Vue restyles every component for free.
Page chrome (background, card, title) gets explicit .is-dark CSS
since the algorithm only covers AD-Vue components.
2. Vite logged every failed proxy attempt loudly. When the Go panel
isn't running locally that's pure noise. Added a configure()
callback that swallows ECONNREFUSED specifically; real errors
(timeouts, 5xx, anything else) still surface.
Both fixes are dev-experience only — production build is unchanged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
import { defineConfig } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import path from 'node:path';
|
|
|
|
// Output goes to web/dist/ at the repo root so the Go binary can embed it
|
|
// via embed.FS without reaching outside the web/ tree.
|
|
const outDir = path.resolve(__dirname, '../web/dist');
|
|
|
|
// Build a proxy config that suppresses ECONNREFUSED noise when the Go
|
|
// backend isn't running locally. Real errors (timeouts, 5xx, etc.) still
|
|
// surface in the Vite log.
|
|
function makeBackendProxy(target, patterns) {
|
|
const config = {};
|
|
for (const pattern of patterns) {
|
|
config[pattern] = {
|
|
target,
|
|
changeOrigin: true,
|
|
configure(proxy) {
|
|
proxy.on('error', (err) => {
|
|
if (err.code === 'ECONNREFUSED') return;
|
|
// eslint-disable-next-line no-console
|
|
console.error('[proxy]', err);
|
|
});
|
|
},
|
|
};
|
|
}
|
|
return config;
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [vue()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
build: {
|
|
outDir,
|
|
emptyOutDir: true,
|
|
sourcemap: true,
|
|
target: 'es2020',
|
|
// Multiple HTML entries — one per legacy page we migrate.
|
|
// As pages get ported in later phases, add their entrypoints here.
|
|
rollupOptions: {
|
|
input: {
|
|
index: path.resolve(__dirname, 'index.html'),
|
|
login: path.resolve(__dirname, 'login.html'),
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
strictPort: true,
|
|
proxy: makeBackendProxy('http://localhost:2053', [
|
|
// Patterns are anchored regex so /login.html and /index.html
|
|
// (which Vite serves itself) are NOT forwarded — only the bare
|
|
// backend paths and their sub-routes.
|
|
'^/(login|logout|getTwoFactorEnable)$',
|
|
'^/(panel|server)(/|$)',
|
|
]),
|
|
},
|
|
});
|