Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-environment

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-environment

Easily expose environment variables in Vite.js

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is vite-plugin-environment?

vite-plugin-environment is a Vite plugin that allows you to inject environment variables into your Vite project. This can be particularly useful for managing different configurations for development, staging, and production environments.

What are vite-plugin-environment's main functionalities?

Basic Environment Variable Injection

This feature allows you to inject basic environment variables into your Vite project. In this example, `NODE_ENV` and `API_URL` are injected into the project.

import { defineConfig } from 'vite';
import EnvironmentPlugin from 'vite-plugin-environment';

export default defineConfig({
  plugins: [
    EnvironmentPlugin({
      NODE_ENV: 'development',
      API_URL: 'https://api.example.com'
    })
  ]
});

Custom Prefix for Environment Variables

This feature allows you to use a custom prefix for your environment variables. In this example, `MY_APP_API_KEY` is injected with a custom prefix `MY_APP_`.

import { defineConfig } from 'vite';
import EnvironmentPlugin from 'vite-plugin-environment';

export default defineConfig({
  plugins: [
    EnvironmentPlugin({
      CUSTOM_PREFIX: 'MY_APP_',
      MY_APP_API_KEY: '12345'
    })
  ]
});

Loading Environment Variables from .env Files

This feature allows you to load environment variables from .env files. In this example, all environment variables defined in the .env file are injected into the project.

import { defineConfig } from 'vite';
import EnvironmentPlugin from 'vite-plugin-environment';
import dotenv from 'dotenv';

dotenv.config();

export default defineConfig({
  plugins: [
    EnvironmentPlugin(process.env)
  ]
});

Other packages similar to vite-plugin-environment

Keywords

FAQs

Package last updated on 19 Oct 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc