Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@0kzh/babel-plugin-transform-vite-meta-env
Advanced tools
babel plugin that emulates vite's import.meta.env functionality
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.
In
const mode = import.meta.env.MODE;
const baseUrl = import.meta.env.BASE_URL;
const nodeEnv = import.meta.env.NODE_ENV;
const dev = import.meta.env.DEV;
const prod = import.meta.env.PROD;
const viteVar = import.meta.env.VITE_VAR;
const other = import.meta.env.OTHER;
const env = import.meta.env;
Out
const mode = process.env.MODE;
const baseUrl = '/';
const nodeEnv = process.env.NODE_ENV || 'test';
const dev = process.env.NODE_ENV !== 'production';
const prod = process.env.NODE_ENV === 'production';
const viteVar = process.env.VITE_VAR;
const other = {
...Object.fromEntries(Object.entries(process.env).filter(([k]) => /^VITE_/.test(k))),
NODE_ENV: process.env.NODE_ENV || 'test',
MODE: process.env.NODE_ENV || 'test',
BASE_URL: '/',
DEV: process.env.NODE_ENV !== 'production',
PROD: process.env.NODE_ENV === 'production'
}.OTHER;
const env = {
...Object.fromEntries(Object.entries(process.env).filter(([k]) => /^VITE_/.test(k))),
NODE_ENV: process.env.NODE_ENV || 'test',
MODE: process.env.NODE_ENV || 'test',
BASE_URL: '/',
DEV: process.env.NODE_ENV !== 'production',
PROD: process.env.NODE_ENV === 'production'
};
npm install --save-dev babel-plugin-transform-vite-meta-env
{
"plugins": ["babel-plugin-transform-vite-meta-env"]
}
babel --plugins babel-plugin-transform-vite-meta-env script.js
require('@babel/core').transformSync('code', {
plugins: ['babel-plugin-transform-vite-meta-env']
})
FAQs
babel plugin that emulates vite's import.meta.env functionality
The npm package @0kzh/babel-plugin-transform-vite-meta-env receives a total of 2 weekly downloads. As such, @0kzh/babel-plugin-transform-vite-meta-env popularity was classified as not popular.
We found that @0kzh/babel-plugin-transform-vite-meta-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.