import { readFileSync } from 'node:fs';
|
import { resolve } from 'node:path';
|
|
import { defineConfig } from 'vite';
|
|
import { createGatewayConfig } from './src/gateway.mjs';
|
import { parseRegistry } from './src/registry.mjs';
|
|
const registry = parseRegistry(readFileSync(resolve(import.meta.dirname, '../registry.yaml'), 'utf8'));
|
const port = Number(process.env.ONLYOFFICE_GATEWAY_PORT ?? '4173');
|
if (!Number.isInteger(port) || port < 1024 || port > 65_535) throw new Error('ONLYOFFICE_GATEWAY_PORT 无效');
|
|
export default defineConfig(createGatewayConfig(registry, {
|
host: process.env.ONLYOFFICE_GATEWAY_HOST ?? '0.0.0.0',
|
port,
|
}));
|