Skip to content

fix(config): detect vite.config.c[jt]s#4363

Merged
pi0 merged 1 commit into
nitrojs:mainfrom
NaufalK25:nitrovite
Jun 21, 2026
Merged

fix(config): detect vite.config.c[jt]s#4363
pi0 merged 1 commit into
nitrojs:mainfrom
NaufalK25:nitrovite

Conversation

@NaufalK25

Copy link
Copy Markdown
Contributor

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

  • resolveBuilder's hasNitroViteConfig() only checked vite.config.{ts,mts,js,mjs} when auto-detecting the vite builder, missing .cjs/.cts configs.
  • Vite itself already resolves vite.config.cjs and vite.config.cts as first-class config files (see DEFAULT_CONFIG_FILES in vite's constants.ts, and the Vite config docs: "other JS and TS extensions are also supported"). Nitro's own builder detection was just out of sync with that list.
  • Added .cjs and .cts to configExts so a vite.config.cjs/.cts containing the nitro() plugin is now correctly detected and builder defaults to "vite".

📝 Checklist

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

@NaufalK25 NaufalK25 requested a review from pi0 as a code owner June 20, 2026 09:58
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@NaufalK25 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 Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

hasNitroViteConfig in src/config/resolvers/builder.ts gains two additional Vite config file extensions — .cts and .cjs — expanding configExts from four entries to six to cover CommonJS TypeScript and JavaScript variant filenames.

Changes

Vite Config Extension Detection

Layer / File(s) Summary
Add .cts and .cjs to configExts
src/config/resolvers/builder.ts
configExts in hasNitroViteConfig is extended with ".cts" and ".cjs", so projects using those Vite config file extensions are now detected.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • nitrojs/nitro#4058: Introduced hasNitroViteConfig with the original multi-extension scanning logic that this PR extends with .cts/.cjs.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is related to the changeset, explaining why .cjs and .cts support was added to align with Vite's configuration file resolution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The pull request title 'fix(config): detect vite.config.c[jt]s' follows the conventional commits format with a 'fix' type and descriptive scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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 and usage tips.

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thnx!

@pi0 pi0 changed the title fix(config): support vite.config.cjs/.cts in builder auto-detection for nitroVite fix(config): detect vite.config.c[jt]s Jun 21, 2026
@pi0 pi0 merged commit f366b25 into nitrojs:main Jun 21, 2026
8 of 9 checks passed
@NaufalK25 NaufalK25 deleted the nitrovite branch June 21, 2026 08:16
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.

2 participants