diff --git a/.changeset/tough-lamps-agree.md b/.changeset/tough-lamps-agree.md new file mode 100644 index 00000000..ff394b75 --- /dev/null +++ b/.changeset/tough-lamps-agree.md @@ -0,0 +1,5 @@ +--- +"@vocab/core": minor +--- + +Add support for a alternative config file name, `vocab.config.cjs` diff --git a/README.md b/README.md index 9905e0aa..2aa0b1a7 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ $ npm i --save @vocab/core @vocab/react ### Step 2: Configure Vocab -You can configure Vocab directly when calling the API or via a `vocab.config.js` file. +You can configure Vocab directly when calling the API or via a `vocab.config.js` or `vocab.config.cjs` file. In this example we've configured two languages, English and French, where our initial `translation.json` files will use English. @@ -184,7 +184,7 @@ t('my key with component', { ## Configuration -Configuration can either be passed into the Node API directly or be gathered from the nearest _vocab.config.js_ file. +Configuration can either be passed into the Node API directly or be gathered from the nearest _vocab.config.js_ or _vocab.config.cjs_ file. **vocab.config.js** @@ -341,7 +341,7 @@ functionality. ### Generating a pseudo-localized language using Vocab -Vocab can generate a pseudo-localized language via the [`generatedLanguages` config][generated languages config], either via the webpack plugin or your `vocab.config.js` file. +Vocab can generate a pseudo-localized language via the [`generatedLanguages` config][generated languages config], either via the webpack plugin or your `vocab.config.js` or `vocab.config.cjs` file. `@vocab/pseudo-localize` exports a `generator` that can be used directly in your config. **vocab.config.js** diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index cfde48ab..9b325ba3 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -177,7 +177,7 @@ export async function resolveConfig( ): Promise { const configFilePath = customConfigFilePath ? path.resolve(customConfigFilePath) - : await findUp('vocab.config.js'); + : await findUp(['vocab.config.js', 'vocab.config.cjs']); if (configFilePath) { trace(`Resolved configuration file to ${configFilePath}`); @@ -192,7 +192,7 @@ export function resolveConfigSync( ): UserConfig | null { const configFilePath = customConfigFilePath ? path.resolve(customConfigFilePath) - : findUp.sync('vocab.config.js'); + : findUp.sync(['vocab.config.js', 'vocab.config.cjs']); if (configFilePath) { trace(`Resolved configuration file to ${configFilePath}`);