Package Exports
- babel-preset-vite
- babel-preset-vite/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-preset-vite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
babel-preset-vite
Please note: this plugin is intended to provide an approximation of some of Vite specific transformations when running the code in non-Vite environment, for example, running tests with a NodeJS based test runner.
The functionality within these transformations should not be relied upon in production.
This preset includes the following plugins:
- babel-plugin-transform-vite-meta-env
- babel-plugin-transform-vite-meta-glob
- babel-plugin-transform-vite-meta-hot
Installation
npm install --save-dev babel-preset-vite
Usage
With a configuration file (Recommended)
Without options:
{
"presets": ["babel-preset-vite"]
}
With options:
{
"presets": [
[
"babel-preset-vite",
{
"env": false, // defaults to true
"glob": false, // defaults to true
"hot": false // defaults to true
}
]
]
}
Via CLI
babel --presets babel-preset-vite
Via Node API
require('@babel/core').transformSync('code', {
presets: ['babel-preset-vite']
})
Options
env
boolean
, defaults to true
Toggles whether or not to perform
import.meta.env
transformations.
glob
boolean
, defaults to true
Toggles whether or not to perform
import.meta.glob
and import.meta.globEager
transformations.
hot
boolean
, defaults to true
Toggles whether or not to perform import.meta.hot
transformations.
You can read more about configuring preset options here