diff --git a/docs/introduction.md b/docs/introduction.md index 63c266110..27cffbdb2 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -94,4 +94,8 @@ This means you can configure Kubb via (in order of precedence): - A `.kubbrc.js`, `.kubbrc.cjs`, `kubb.config.js`, or `kubb.config.cjs` file that exports an object using module.exports. - A `.kubbrc.ts` or `kubb.config.ts` file that exports an object using export default. +::: tip +You can also use `configs/kubb.config.ts` or `.config/kubb.config.ts` instead of `kubb.config.ts` in the root of your project. +::: + See [kubb.config.js](/configuration/options) on how to configure Kubb. \ No newline at end of file diff --git a/examples/advanced/kubb.config.ts b/examples/advanced/configs/kubb.config.ts similarity index 100% rename from examples/advanced/kubb.config.ts rename to examples/advanced/configs/kubb.config.ts diff --git a/examples/advanced/package.json b/examples/advanced/package.json index 714c23802..d3924dabd 100644 --- a/examples/advanced/package.json +++ b/examples/advanced/package.json @@ -13,11 +13,11 @@ "scripts": { "build": "tsup", "clean": "npx rimraf ./dist", - "generate": "kubb generate --config kubb.config.ts", + "generate": "kubb generate", "generate:bun": "bun ./node_modules/@kubb/cli/bin/kubb.js generate --config .kubbrc.js", "generate:js": "kubb generate --config .kubbrc.js", "generate:json": "kubb generate --config kubb.json", - "generate:ts": "kubb generate --config kubb.config.ts", + "generate:ts": "kubb generate --config configs/kubb.config.ts", "start": "tsup --watch", "test": "vitest", "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false" diff --git a/examples/advanced/tsconfig.json b/examples/advanced/tsconfig.json index 06de0d0f2..66a1b9f28 100644 --- a/examples/advanced/tsconfig.json +++ b/examples/advanced/tsconfig.json @@ -83,7 +83,7 @@ }, "include": [ "./src/**/*", - "kubb.config.ts" + "configs/kubb.config.ts" ], "exclude": [ "**/node_modules", diff --git a/packages/cli/src/utils/getCosmiConfig.ts b/packages/cli/src/utils/getCosmiConfig.ts index a97559521..e4ff8a66c 100644 --- a/packages/cli/src/utils/getCosmiConfig.ts +++ b/packages/cli/src/utils/getCosmiConfig.ts @@ -36,24 +36,33 @@ const tsLoader = (configFile: string) => { } export async function getCosmiConfig(moduleName: string, config?: string): Promise { + const searchPlaces = [ + 'package.json', + `.${moduleName}rc`, + `.${moduleName}rc.json`, + `.${moduleName}rc.yaml`, + `.${moduleName}rc.yml`, + + `.${moduleName}rc.ts`, + `.${moduleName}rc.js`, + `.${moduleName}rc.cjs`, + `.${moduleName}rc.mjs`, + + `${moduleName}.config.ts`, + `${moduleName}.config.js`, + `${moduleName}.config.cjs`, + `${moduleName}.config.mjs`, + ] const explorer = cosmiconfig(moduleName, { cache: false, searchPlaces: [ - 'package.json', - `.${moduleName}rc`, - `.${moduleName}rc.json`, - `.${moduleName}rc.yaml`, - `.${moduleName}rc.yml`, - - `.${moduleName}rc.ts`, - `.${moduleName}rc.js`, - `.${moduleName}rc.cjs`, - `.${moduleName}rc.mjs`, - - `${moduleName}.config.ts`, - `${moduleName}.config.js`, - `${moduleName}.config.cjs`, - `${moduleName}.config.mjs`, + ...searchPlaces.map((searchPlace) => { + return `.config/${searchPlace}` + }), + ...searchPlaces.map((searchPlace) => { + return `configs/${searchPlace}` + }), + ...searchPlaces, ], loaders: { '.ts': tsLoader,