A Babel preset that emulates Vite's non-standard functionality in non-Vite environments, primarily for testing with Node.js-based runners. Version 1.1.3 (stable) includes three plugins: babel-plugin-transform-vite-meta-env (import.meta.env), babel-plugin-transform-vite-meta-glob (import.meta.glob), and babel-plugin-transform-vite-meta-hot (import.meta.hot). Each plugin can be individually disabled via preset options. The preset ships TypeScript types and follows a monthly release cadence with bug fixes. Key differentiator: allows code using Vite-specific features to run in Jest or other Node.js test runners without modification.
npm install babel-preset-viteVerified import paths — ran on the pinned version, not inferred.
Shows installation, configuration with options, and example Vite features transformed by the preset.
Only use in development/test environments.
Upgrade to >=1.1.0 if you need HMR stubs.
Switch to import.meta.glob('./*.js', { eager: true }).Upgrade to >=1.1.2.
Upgrade to >=1.0.3.
Use [["babel-preset-vite", { "env": true }]] instead of ["babel-preset-vite", { "env": true }].Run npm install to ensure all dependencies are installed.
Use require() or set type: 'commonjs' in babel.config.
Add 'babel-preset-vite' to presets in babel.config.js or .babelrc.