Issue sourcecodedir
always overriding vitest root configuration
#334
Labels
help wanted
Extra attention is needed
bundle update vite_ruby
.Description 📖
vite-plugin-ruby
sets the vite server root configuration https://vitejs.dev/config/shared-options.html#root from the configuration found in the json filesourceCodeDir
sourcecodedir
is used for the aliases@
and~
but also to fetch the list of assets/files to watch for rebuild.By default it is set to
app/frontend
Because the plugin make it so
vite.root = 'app/frontend'
any paths sent via option to vite have to be relative to that folderThis leads to issue with
vitest
with reporters paths but also include / excludes paths
in that example
./path/to/reporter.js
is relative tosourcecodedir
Why is it an issue ?
In jetbrains IDE (like rubymine) when executing a vitest bin the IDE will send the reporter path relative to the root of the project
which does not match the
sourcecodedir
and the IDE has no way (i dont think) to get that path value and set the right path for their custom reporters.e.g
because root is now
app/frontend
the correct path for that reporter should be../../../../../../Applications/RubyMine.app/Contents/plugins/javascript-impl/helpers/vitest-intellij/node_modules/vitest-intellij-safe.js
(notice the extra
../../
)How can we make it work ?
a) we can use the vitest root configuration , unfortunately because it is configured via vite plugin and vitest plugin is executed BEFORE the ruby vite plugin the root configuration is always overridden by
sourcecodedir
b) the project can use
./
as value forsourcecodedir
-> problem ?
bin/vite
executable will take forever to execute because it now has to scan ALL files in your project in order to watch the files and trigger an automatic build of the asset on file change!-> other problem is all the fancy aliases
@
and~
now kindof pointless.c) We could make it so ruby plugin does not set the root configuration on
mode = test
-> problem this will force people to specify a root in vite.config.js and not rely on
sourcecodedir
d) And last solution which I ended up doing but is quite hacky, is to create a custom
fixViteTestPlugin
that will change back the root value to the one set by vitetest only when running tests.That way i can have best of both world. using sourcecode dir for
app/frontend
and all my test are in./specs
and rubymine worksThat is it for me. I am not too sure in what project this should be fixed, ruby vite ? vitest ? or just rubymine.
Open to suggestion
Vite Ruby Info
Run
bin/rake vite:info
and provide the output:The text was updated successfully, but these errors were encountered: