← All tools

dotenv-mono

Popularity 65 Updated Development & Build

This package permit to have a centralized dotenv on a monorepo. It also includes some extra features such as manipulation and saving of changes to the dotenv file, a default centralized file, and a file loader with ordering and priorities.

npmauto-collected

Installation

npm
npm install -g dotenv-mono

Install with npm.

<div align="center"

Dotenv mono

If this project has helped you out, please support us with a star 🌟

<br

</div

📘 Description

#### What is this?

To prevent code duplication and enhance re-usability, a centralized configuration including all of your environment variables might be handy. Rather of generating a .env file for each package, we may utilize a single .env file at the project's root.

This is a package that allows monorepo applications and packages to share and load a centralized dotenv. It's based over dotenv package.

It also includes some extra features such as manipulation and saving of changes to the dotenv file, a default centralized file, and a file loader with ordering and priorities.

The plugin dotenv-expand is enabled by default.

##### Structure Example

├── .env
├── .env.production
├── .env.defaults
├── packages
│   ├── ui-library
│   ├── other-library
├── apps
│   ├── web
│   │   ├── .storybook
│   ├── docs

#### How it works?

The package search the first .env file, matching with some priority criteria, by walking up the parent directories.

##### Priorities

Starting from the current process directory, this package finds the first file that matches the best filepath and filename criteria with the highest priority. The greater the depth of the up folder, the lesser its priority.

The priority can be customized on the configuration with the priorities property, see the example below on the usage section.