
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
vite-define-envs-plugin
Advanced tools
Embed environment variables as global constants for local js files.
Embed environment variables as global constants for local js files.
vite-define-envs-plugin
will read from Node's process.env
and define specific environment variables as global constants for client JavaScript.
npm install --save-dev vite-define-envs-plugin
keys
- array of keys to read from process.env
.scope
- scope of the global constants. Default to "process.env" if not set.// vite.config.js
import viteDefineEnvs from "vite-define-envs-plugin";
export default {
plugins: [
new viteDefineEnvs(["USER", "API_BASE_URL"], "GLOBAL")
]
};
// your .js file
const appEnv = GLOBAL.USER;
const apiUrl = GLOBAL.API_BASE_URL;
It's not recommended to use process.env
scope since it's not the same process.env
that Node
uses.
Local js files don't know about process.env
, so the environment variables have to be processed and embedded by vite
during the build time. On the other hand, in a Node
application, process.env
is a Node
module and is injected at runtime.
FAQs
Embed environment variables as global constants for local js files.
The npm package vite-define-envs-plugin receives a total of 59 weekly downloads. As such, vite-define-envs-plugin popularity was classified as not popular.
We found that vite-define-envs-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.