Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for vocab.config.cjs #176

Merged
merged 4 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tough-lamps-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vocab/core": minor
---

Add support for a alternative config file name, `vocab.config.cjs`
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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**

Expand Down Expand Up @@ -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**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export async function resolveConfig(
): Promise<UserConfig | null> {
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}`);
Expand All @@ -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}`);
Expand Down