Skip to content

docs: list supported configuration file names - #4517

Open
tarikermis wants to merge 2 commits into
nitrojs:mainfrom
tarikermis:docs/config-file-names
Open

docs: list supported configuration file names#4517
tarikermis wants to merge 2 commits into
nitrojs:mainfrom
tarikermis:docs/config-file-names

Conversation

@tarikermis

Copy link
Copy Markdown

🔗 Linked issue

Closes #4505

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)

📚 Description

What: adds a "Supported configuration files" section to the Configuration docs page listing exactly which config files Nitro loads, and removes two documented claims that do not hold.

Why: as reported in #4505, the docs never stated which configuration file names are supported, making it impossible to tell whether e.g. .nitrorc.js, nitro.config.yaml, or .config/nitro.toml work.

Every listed filename/location was verified two ways:

  1. In source: Nitro loads config via c12 (loadConfig/watchConfig with name: "nitro", cwd = the rootDir override, i.e. the CLI dir argument defaulting to the current working directory — src/config/loader.ts, src/cli/commands/build.ts). c12 (4.0.0-beta.5, resolveConfig in node_modules/c12/dist/index.mjs:324) resolves nitro.config.config/nitro.config/nitro.config (first match wins) with extensions .js/.ts/.mjs/.cjs/.mts/.cts/.json/.jsonc/.json5/.yaml/.yml/.toml, and always reads an extensionless .nitrorc (rc9 key=value syntax) from the same directory, merged with lower priority than the main file.
  2. Empirically, by running Nitro's actual loadOptions() against temp directories containing each candidate file:
    • ✅ loaded: nitro.config.{ts,js,mjs,cjs,mts,cts,json,jsonc,json5,yaml,yml,toml}, .config/nitro.*, .config/nitro.config.* (same extensions), .nitrorc
    • ❌ not loaded: .nitrorc.{json,js,yaml}, .config/.nitrorc, package.json nitro key, ~/.nitrorc
    • precedence confirmed: root nitro.config.* > .config/nitro.* > .config/nitro.config.*; main config file > .nitrorc

Removed claims (both verified non-functional, not just undocumented):

  • "Config from package.json" — c12 only loads the package.json key when its packageJson option is enabled, and Nitro never enables it (also true for Nitro v2's loader with c12 v2/v3, so this is a docs inaccuracy rather than a v3 regression).
  • .nitrorc "in the user's home directory" — c12 only reads rc files outside the cwd when its globalRc option is enabled, which Nitro also never sets.

Note for maintainers (out of scope here): getConf in src/config/loader.ts:101 still reads rawConfigs.packageJson, which can never be populated — worth either enabling packageJson: true or dropping that read as a follow-up.

Checks run: pnpm lint (oxlint + oxfmt) ✅; docs pnpm build (undocs/Nuxt, 359 routes prerendered) ✅ with the new section present in the built output; empirical config-loading probe as described above ✅. Docs-only change, so no unit tests apply. The diff was reviewed by claude-opus-5 via kiro-cli (read-only); its findings (order-claim phrasing, rc directory precision, Vite inline-config mention) are incorporated.

Limitations: verified on Linux/Node 22 against main @ 52abde8; I did not test Windows path handling. The extension-level priority within one basename (c12 checks .js before .ts) is intentionally left undocumented as an edge case.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Document the exact configuration files Nitro loads via c12:
nitro.config.* (12 extensions), .config/nitro.* and
.config/nitro.config.*, plus the extensionless .nitrorc file.

Also remove two inaccurate claims: configuration via the
package.json nitro key and a .nitrorc in the user home
directory are not loaded (c12 packageJson/globalRc options
are not enabled by Nitro).

Closes nitrojs#4505
@tarikermis
tarikermis requested a review from pi0 as a code owner August 8, 2026 23:17
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@tarikermis is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: baf5542a-284a-4911-b63a-0da8216a7876

📥 Commits

Reviewing files that changed from the base of the PR and between 58863e9 and 8bd3f3a.

📒 Files selected for processing (1)
  • docs/1.docs/50.configuration.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/1.docs/50.configuration.md

📝 Walkthrough

Walkthrough

The configuration documentation now lists supported Nitro configuration filenames, lookup order, project-root resolution, .nitrorc precedence, and inline Vite options. It replaces generic c12 guidance and removes the package.json configuration section.

Changes

Configuration documentation

Layer / File(s) Summary
Document configuration loading rules
docs/1.docs/50.configuration.md
The guide defines supported configuration filenames, lookup order, project-root resolution, .nitrorc merging precedence, and inline Vite configuration.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • nitrojs/nitro#4363: Expands supported Vite configuration file extensions used during configuration detection.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the conventional commit format and accurately describes the documentation change.
Description check ✅ Passed The description clearly explains the supported configuration files, removed inaccurate claims, and verification performed.
Linked Issues check ✅ Passed The PR addresses issue #4505 by documenting supported filenames, extensions, lookup order, and unsupported variants.
Out of Scope Changes check ✅ Passed The changes are limited to the configuration documentation requested by issue #4505.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/1.docs/50.configuration.md`:
- Around line 41-45: Update the configuration file lists in the Nitro
configuration documentation to reflect c12’s actual extension precedence,
placing JavaScript extensions before TypeScript extensions. Apply the same
ordering consistently to all three locations: nitro.config, .config/nitro, and
.config/nitro.config.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e4397044-9b7b-49a4-bfdd-2009d3845724

📥 Commits

Reviewing files that changed from the base of the PR and between 52abde8 and 58863e9.

📒 Files selected for processing (1)
  • docs/1.docs/50.configuration.md

Comment thread docs/1.docs/50.configuration.md Outdated
c12 resolves .js before .ts for the same basename, so list the
extensions in the order they are actually checked.

Refs nitrojs#4505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Which config files are supported?

1 participant