diff options
Diffstat (limited to 'src/config.ts')
-rw-r--r-- | src/config.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/config.ts b/src/config.ts index 937499923..af618a27f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -24,6 +24,10 @@ function validateConfig(config: any): void { throw new Error(`[astro config] ${key}: ${JSON.stringify(config[key])}\n Expected boolean, received ${type(config[key])}.`); } } + + if(config.devOptions?.port !== 'number') { + throw new Error(`[astro config] devOptions.port: Expected number, received ${type(config.devOptions?.port)}`) + } } /** Set default config values */ @@ -34,7 +38,8 @@ function configDefaults(userConfig?: any): any { if (!config.astroRoot) config.astroRoot = './astro'; if (!config.dist) config.dist = './_site'; if (!config.public) config.public = './public'; - + if (!config.devOptions) config.devOptions = {}; + if (!config.devOptions.port) config.devOptions.port = 3000; if (typeof config.sitemap === 'undefined') config.sitemap = true; return config; @@ -53,13 +58,13 @@ function normalizeConfig(userConfig: any, root: string): AstroConfig { } /** Attempt to load an `astro.config.mjs` file */ -export async function loadConfig(rawRoot: string | undefined): Promise<AstroConfig> { +export async function loadConfig(rawRoot: string | undefined, configFileName = 'astro.config.mjs'): Promise<AstroConfig> { if (typeof rawRoot === 'undefined') { rawRoot = process.cwd(); } const root = pathResolve(rawRoot); - const astroConfigPath = pathJoin(root, 'astro.config.mjs'); + const astroConfigPath = pathJoin(root, configFileName); // load let config: any; |