MCPcopy Index your code
hub / github.com/Andarist/rollup-plugin-dotenv

github.com/Andarist/rollup-plugin-dotenv @v0.5.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.1 ↗ · + Follow
7 symbols 18 edges 4 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rollup-plugin-dotenv

Installation

npm install rollup-plugin-dotenv

Usage

Create a rollup.config.js configuration file and import the plugin:

import dotenv from "rollup-plugin-dotenv"

export default {
  input: "src/index.js",
  output: [
    dir: "dist/build"
  ],
  plugins: [
    dotenv()
  ]
}

create your .env file in the root of your project.

# .env
FOO=bar

so you can use FOO in your javascript files.

// src/index.js
console.log(process.env.FOO)

your env variables will be replaced by their values in your bundled file.

// dist/build/index.js
console.log('bar')

if you want to know more about the principle and restrictions of replacement, please read @rollup/plugin-replace notes.

Options

You can specify the options below.

cwd

Type: String Default: "."

directory in which to search for env files.

envKey

Type: String Default: "NODE_ENV"

key used to search for .env files by node environment

Rollup will merge env vars located at

[
  `.env.${process.env[envKey]}.local`,
  `.env.${process.env[envKey]}`,
  '.env.local',
  '.env',
]

so if you are in prod, rollup will search in

['.env.prod.local', '.env.prod', '.env.local', '.env']

and merge the result.

LICENSE (MIT)

Extension points exported contracts — how you extend this code

RollupDotenvOptions (Interface)
(no doc)
src/index.d.ts

Core symbols most depended-on inside this repo

withDefaults
called by 1
src/index.js
mapKeys
called by 1
src/utils.js
mapValues
called by 1
src/utils.js
pick
called by 1
src/utils.js
shallowMergeAll
called by 1
src/utils.js
dotenvPlugin
called by 0
src/index.js

Shape

Function 6
Interface 1

Languages

TypeScript100%

Modules by API surface

src/utils.js4 symbols
src/index.js2 symbols
src/index.d.ts1 symbols

For agents

$ claude mcp add rollup-plugin-dotenv \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page