Bilibili-Evolved/dev-tools/dev-server/config.ts
2022-10-12 23:25:10 +08:00

20 lines
520 B
TypeScript

import { readFileSync, existsSync } from 'fs'
interface DevServerConfig {
port?: number
maxWatchers?: number
}
const configFile = (path: string) => () =>
existsSync(path) ? JSON.parse(readFileSync(path, { encoding: 'utf-8' })) : {}
const configSource: (() => DevServerConfig)[] = [
() => ({
port: 23333,
maxWatchers: 16,
}),
configFile('dev/dev-server.json'),
]
export const devServerConfig = configSource.reduce(
(previous, current) => ({ ...previous, ...current() }),
{} as DevServerConfig,
)