Migrating to Vite
If you would like to add a note about Sprockets, pull requests are welcome!
Starting Fresh ☀️
During installation, Vite Ruby detect if the
config/vite.json instead of the default.
One entry at a time
The recommended approach for medium-to-large-sized applications is to migrate one entrypoint at a time if possible. Gradually move each file in
Check this migration from Webpacker as an example.
Proceed to fix any errors that occur (i.e. differences between Webpack and Vite.js) by checking the Troubleshooting section and the following recommendations:
Explicitly add a file extension to any non-JS imports.
- import TextInput from '@/components/TextInput' + import TextInput from '@/components/TextInput.vue'
- const context = require.context("./controllers", true, /\.js$/) + const controllers = import.
Loaders to Plugins
Vite provides many features out of the box, which reduce the need for configuration.
In complex setups, the app might depend on specific webpack loaders, which can't be used in Vite, which uses Rollup under the hood.