EENE Dashboard upload to Gitea
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,27 +1,69 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import type { Plugin } from 'vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import path from 'path';
|
||||
import basicSsl from '@vitejs/plugin-basic-ssl';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
/** http-local: http://localhost:3000 | https-lan: https://{LAN IP}:3000 */
|
||||
function readLanIp(): string | null {
|
||||
const file = path.join(__dirname, '.lan-ip');
|
||||
if (!fs.existsSync(file)) return null;
|
||||
const ip = fs.readFileSync(file, 'utf8').trim();
|
||||
return ip || null;
|
||||
}
|
||||
|
||||
function lanOnlyUrls(lanHost: string, port: number): Plugin {
|
||||
return {
|
||||
name: 'lan-only-urls',
|
||||
configureServer(server) {
|
||||
server.printUrls = () => {
|
||||
server.config.logger.info(`\n ➜ LAN: https://${lanHost}:${port}/\n`, { clear: true });
|
||||
};
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
host: true, // 0.0.0.0 — 같은 네트워크 팀원 접속 허용
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:4000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/uploads': {
|
||||
target: 'http://localhost:4000',
|
||||
changeOrigin: true,
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const isHttpsLan = mode === 'https-lan';
|
||||
const lanHost = readLanIp();
|
||||
|
||||
if (isHttpsLan && !lanHost) {
|
||||
throw new Error('frontend/.lan-ip missing — restart via 서버시작.bat');
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss(),
|
||||
...(isHttpsLan ? [basicSsl(), lanOnlyUrls(lanHost!, 3000)] : []),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
strictPort: true,
|
||||
host: isHttpsLan ? lanHost! : 'localhost',
|
||||
https: isHttpsLan,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:4000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/uploads': {
|
||||
target: 'http://localhost:4000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/socket.io': {
|
||||
target: 'http://localhost:4000',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user