Moving to Vite
If you have an existing Vue CLI project it’s relatively straightforward to move over. There are a few things to keep in mind.
Vite exposes env variables on the
import.meta.env global. Evan describes how to use this in the video, and you can read more in this documentation.
Require vs Import
When using webpack you might use
require calls. In Vite we strongly recommend against
require, because it’s technically a node.js concept and it won’t work well with Vite. However, if you’re using a depedency that uses
require Vite will handle that.
This is a feature of webpack that allows you to look at the files of a directory at runtime. Vite has an equivalent called Glob Import, which you’ll want to use instead.