Skip to content
On this page

Upgrading to Vite 3

Vite 3 has been released!

Check the Migration Guide and the Changelog for more information.

Upgrading in Vite Ruby

Migrating to Vite 3

Follow Vite's Migration Guide and read the Changelog for more information.

For most Vite Ruby apps, you'll likely be able to upgrade without having to make any code changes.

You can upgrade by running bin/vite upgrade, which will bump vite_ruby and any related dependencies to the latest version.

Latest Version

At the time of writing, the latest version is vite_ruby-3.2.0, targeting the new Vite 3 release.

Version Numbers

From now on, versions of vite_ruby will match Vite's major version number, for simplicity.

import.meta.glob changes

In Vite 3, import.meta.glob will use keys relative to the current module.

// app/frontend/controllers/index.js
const controllers = import.meta.globEager('../**/*_controller.js')

That code now transforms to:

const controllers = {
-  '../controllers/home_controller.js': () => {}
+  './home_controller.js': () => {}
}

This can affect any usages that rely on the full path, such as when using stimulus-vite-helpers.

Depending on the the pattern you might not need to make any changes, but if you need the full path, you can leverage the new support for aliases:

const controllers = import.meta.globEager('~/controllers/**/*_controller.js')

Prefer Aliases

An advantage of using aliases is that it's more explicit, works regardless of the file location, making it more robust when refactoring.

Upgrading to Vite 3 has loaded