ElMassimo / vite_ruby

⚡️ Vite.js in Ruby, bringing joy to your JavaScript experience
https://vite-ruby.netlify.app/
MIT License
1.28k stars 117 forks source link

Allow `.` as a valid option for `sourceCodeDir` #425

Open davidmyersdev opened 9 months ago

davidmyersdev commented 9 months ago

Is your feature request related to a problem? Please describe.

My team uses a mono-repo setup that uses Packwerk. We have various packs at paths such as ./packs/<package> and under those packs can be frontend assets at ./packs/<package>/app/frontend. These packs reside next to a traditional top-level Rails app which hosts assets at ./app/frontend. These all share a common configuration for Vite Ruby, and that means we would ideally set our sourceCodeDir to . so that all paths can be made relative to the root of the project. This seems to work just fine, but the default glob that is assigned to sourceCodeDir means that all files (./**/*) are scanned by Vite Ruby. This leads to long wait times for commands that trigger Vite Ruby to scan all files (e.g. the bin/vite build command).

Describe the solution you'd like

I'd like to be able to override the default file globs so that I can set the sourceCodeDir to ..

Describe alternatives you've considered

Currently, I set it up so that I have a default sourceCodeDir of ./app/frontend with the others added to additionalEntrypoints and watchAdditionalPaths. The problem with this approach is that the Vite root ends up getting set to ./app/frontend and I have to configure Vitest along with various plugins relative to that path even when the tests are not in the root project. It leads to confusing configurations if you are not aware of what Vite Ruby is doing behind the scenes.

Additional context

N/A