From 0414482795676a8bd74510e044f138ca544710bb Mon Sep 17 00:00:00 2001 From: Pringgo Radianto Date: Tue, 1 Oct 2024 14:32:00 +0700 Subject: [PATCH] feat(config): add configuration file options --- src/module.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/module.ts b/src/module.ts index e13b5b0..c245642 100644 --- a/src/module.ts +++ b/src/module.ts @@ -3,7 +3,7 @@ import { defineNuxtModule, createResolver, addServerPlugin } from '@nuxt/kit' import logger from './runtime/utils/logger' export interface ModuleOptions { - // + configFile?: string } export default defineNuxtModule({ @@ -14,12 +14,15 @@ export default defineNuxtModule({ nuxt: '^3.0.0', }, }, - async setup(_options, nuxt) { + defaults: { + configFile: 'server.config', + }, + async setup(options, nuxt) { const resolver = createResolver(import.meta.url) nuxt.options.alias['#nuxt-proxy-party'] = resolver.resolve('./core') - const serverConfigPath = await resolver.resolvePath('server.config', { + const serverConfigPath = await resolver.resolvePath(options.configFile ?? 'server.config', { cwd: nuxt.options.rootDir, extensions: ['.js', '.mjs', '.ts'], }) @@ -33,7 +36,7 @@ export default defineNuxtModule({ serverConfig = await readFile(serverConfigPath, 'utf8') } catch { - logger.warn('No server.config found') + logger.warn('No config found') } config.virtual['#nuxt-proxy-party-options'] = serverConfig