{"id":13601990,"url":"https://github.com/chihab/dotenv-run","last_synced_at":"2025-05-13T12:52:27.513Z","repository":{"id":37721280,"uuid":"397194725","full_name":"chihab/dotenv-run","owner":"chihab","description":"Seamlessly load environment variables. Supports cli, esbuild, rollup, vite, webpack, angular. ESM and Monorepos.","archived":false,"fork":false,"pushed_at":"2025-04-23T21:39:17.000Z","size":3686,"stargazers_count":281,"open_issues_count":9,"forks_count":21,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-05T11:07:37.632Z","etag":null,"topics":["angular","builder","configuration","dotenv","environment","environment-variables","schematics","system","typescript","variables"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chihab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-08-17T09:40:47.000Z","updated_at":"2025-04-24T16:56:21.000Z","dependencies_parsed_at":"2024-01-17T18:33:23.869Z","dependency_job_id":"7f2e091a-57f8-425b-a655-2ed7ff55629b","html_url":"https://github.com/chihab/dotenv-run","commit_stats":{"total_commits":154,"total_committers":8,"mean_commits":19.25,"dds":0.09090909090909094,"last_synced_commit":"0cd3c697c1eadca1a0d5fb5588b3151f0de8f1a6"},"previous_names":["chihab/ngx-env"],"tags_count":83,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chihab%2Fdotenv-run","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chihab%2Fdotenv-run/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chihab%2Fdotenv-run/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chihab%2Fdotenv-run/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chihab","download_url":"https://codeload.github.com/chihab/dotenv-run/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253947708,"owners_count":21988942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","builder","configuration","dotenv","environment","environment-variables","schematics","system","typescript","variables"],"created_at":"2024-08-01T18:01:11.197Z","updated_at":"2025-05-13T12:52:27.495Z","avatar_url":"https://github.com/chihab.png","language":"TypeScript","readme":"\u003ch1\u003edotenv-run\u003c/h1\u003e\n\n[![monthly downloads](https://img.shields.io/npm/dm/@dotenv-run/core.svg)](https://www.npmjs.com/package/@dotenv-run/core)\n\n`dotenv-run` is a collection of packages that use **dotenv** to support loading environment variables from `.env` files with multiple integrations.\n\nHere are some of the benefits of using `dotenv-run`:\n\n- ✅ **Monorepo ✨**: supports monorepo projects with multiple applications.\n- ✅ **Universal**: supports multiple integrations including CLI, Webpack, Rollup, Vite, ESbuild and Angular.\n- ✅ **TypeScript**: supports TS projects with type definitions for `process.env` and `import.meta.env`.\n- ✅ **ESM**: supports `process.env` and `import.meta.env` in ESM modules.\n- ✅ **Secure**: supports filtering environment variables by prefix.\n\n\u003ch2\u003eIntegrations\u003c/h2\u003e\n\n| Integration     | Package                                   | Status |\n| --------------- | ----------------------------------------- | ------ |\n| CLI             | [@dotenv-run/cli](#dotenv-runcli)         | ✅     |\n| Core            | [@dotenv-run/core](#dotenv-runcore)       | ✅     |\n| ESBuild         | [@dotenv-run/esbuild](#dotenv-runesbuild) | ✅     |\n| Rollup          | [@dotenv-run/rollup](#dotenv-runrollup)   | ✅     |\n| Vite            | [@dotenv-run/vite](#dotenv-runvite)       | ✅     |\n| Node.js preload | @dotenv-run/load                          | ✅     |\n| Angular         | [@ngx-env/builder](#ngx-envbuilder)       | ✅     |\n\n## Quick start\n\n- [Quick start](#quick-start)\n  - [@dotenv-run/cli](#dotenv-runcli)\n  - [@dotenv-run/core](#dotenv-runcore)\n  - [@dotenv-run/esbuild](#dotenv-runesbuild)\n  - [@ngx-env/builder](#ngx-envbuilder)\n- [Testimonials](#testimonials)\n    - [Demos](#demos)\n    - [Quick start](#quick-start-1)\n  - [@dotenv-run/webpack](#dotenv-runwebpack)\n  - [@dotenv-run/rollup](#dotenv-runrollup)\n- [Credits](#credits)\n- [License](#license)\n\nAssuming you have the following monorepo structure:\n\n```shell\nplatform\n├── apps\n│   ├── vite-app\n│   ├── ng-app\n│   └── esbuild-app\n│   │   ├── .env.local # API_BASE=http://localhost:3001\n│   │   ├── package.json\n│   │   └── webapp.config.mjs\n├── libs\n│   └── rollup-lib\n│       ├── package.json\n│       └── rollup.config.mjs\n├── .env.dev # API_BASE=https://dev.dotenv.run\n├── .env.prod # API_BASE=https://prod.dotenv.run\n├── .env # API_USERS=$API_BASE/api/v1/users;API_AUTH=https://$API_BASE/auth\n├── nx.json\n└── package.json\n```\n\nand the following `dotenv-run` options:\n\n```json\n{\n  \"verbose\": true, // print debug information\n  \"unsecure\": true, // display environment variables values\n  \"root\": \"../..\", // root directory to search for .env files\n  \"environment\": \"dev\", // environment to load (default: NODE_ENV)\n  \"files\": [\".env\"], // .env files to load (default: .env)\n  \"prefix\": \"^API_\" // prefix to filter environment variables (used with bundlers)\n}\n```\n\n`dotenv-run` will search and load `.env.*` files located in the root workspace `/home/code/platform` down to the current working directory of the application.\n\n```sh\n- Root directory: /home/code/platform\n- Working directory:  /codes/code/platform/apps/esbuild-app\n- Files: .env\n- Environment: dev\n- Environment files:\n ✔ /home/code/platform/apps/esbuild-app/.env.local\n ✔ /home/code/platform/.env.dev\n ✔ /home/code/platform/.env\n- Environment variables: API (Unsecure Mode)\n ✔ API_USERS http://localhost:3001/api/v1/users\n ✔ API_AUTH https://localhost:3001/auth\n```\n\n### @dotenv-run/cli\n\n[`@dotenv-run/cli`](https://www.npmjs.com/package/@dotenv-run/cli) is a standalone CLI that can be used to run a script.\n\n```sh\n❯ npx dotenv-run\n\n  Usage: dotenv-run [options] -- \u003ccommand\u003e\n\n  Options:\n    -v, --verbose [regexp]         display debug information\n    -u, --unsecure                 display environment variables values\n    -e, --env [environment]        environment to load (default: NODE_ENV)\n    -r, --root                     root directory to search for .env files\n    -f, --file [.env,.secrets]     .env files to load (default: .env)\n    -h, --help                     output usage information\n\n  Examples:\n    dotenv-run -d\n    dotenv-run -- npm start\n    dotenv-run -r ../.. -f .env,.secrets -- npm start\n    dotenv-run -f ../.env,../.env.api -- npm start\n```\n\n### @dotenv-run/core\n\n[`@dotenv-run/core`](https://www.npmjs.com/package/@dotenv-run/core) is the core package that can be used to load environment variables from `.env` files.\n\n```ts\nenv({\n  root: \"../..\",\n  verbose: true,\n  prefix: \"^API_\",\n  files: [\".env\"],\n});\n```\n\n### @dotenv-run/esbuild\n\n[`@dotenv-run/esbuild`](https://www.npmjs.com/package/@dotenv-run/esbuild) is a plugin for esbuild that can be used to inject environment variables into your applications.\n\n```ts\nimport { dotenvRun } from \"@dotenv-run/esbuild\";\n\nawait build({\n  write: false,\n  bundle: true,\n  entryPoints: [`test/app.js`],\n  plugins: [\n    dotenvRun({\n      verbose: true,\n      root: \"../../\",\n      prefix: \"^API\",\n    }),\n  ],\n});\n```\n\n### @ngx-env/builder\n\n[`@ngx-env/builder`](https://www.npmjs.com/package/@ngx-env/builder) is a plugin for Angular CLI and a wrapper around `@dotenv-run/esbuild` or `@dotenv-run/webpack` that can be used to inject environment variables into your Angular applications.\n\n- ✅ Official recommendation in [dotenv documentation](https://www.dotenv.org/docs/frameworks/angular/vercel) 🔥\n- ✅ Webpack and ESBuild support 🚀\n- ✅ Runtime environment variables 🎉\n- ✅ Loading priorities of environment variables with Monorepo Support ([Nx](https://nx.dev), [Turbo](https://turborepo.com/), etc.) ✨\n- ✅ Easy to use, no configuration required\n- ✅ Up to date with latest Angular versions\n- ✅ Supports all Angular CLI commands\n- ✅ Supports `process.env` and `import.meta.env` usage in TypeScript\n- ✅ Filters sensitive variables using a Regular Expression\n- ✅ Used by popular repositories\n  - [Official Microsoft Azure Samples](https://github.com/Azure-Samples/contoso-real-estate) ![GitHub Repo stars](https://img.shields.io/github/stars/Azure-Samples/contoso-real-estate)\n  - [Official Quarkus Workshop](https://github.com/quarkusio/quarkus-workshops) ![GitHub Repo stars](https://img.shields.io/github/stars/quarkusio/quarkus-workshops)\n  - [Scholarsome by Redhat](https://github.com/hwgilbert16/scholarsome) ![GitHub Repo stars](https://img.shields.io/github/stars/hwgilbert16/scholarsome)\n  - [Dan Wahlin's Angular-JumpStart](https://github.com/DanWahlin/Angular-JumpStart) ![GitHub Repo stars](https://img.shields.io/github/stars/DanWahlin/Angular-JumpStart)\n- ✅ Active development and support\n\n## Testimonials\n\n[motdotla](https://github.com/motdotla) - dotenv author and maintainer @**dotenvx**\n\u003cimg src=\"https://github.com/chihab/dotenv-run/raw/main/packages/angular/motdotla.png\" alt=\"Description\" width=\"600\"\u003e\n\nNB: Angular not Angular.js :P\n\n[manekinekko](https://github.com/manekinekko) - SSE @**microsoft**\n\u003cimg src=\"https://github.com/chihab/dotenv-run/raw/main/packages/angular/manekinekko.png\" alt=\"Description\" width=\"600\"\u003e\n\n#### Demos\n\n- [v19 with vite/esbuild builder](https://stackblitz.com/edit/ngx-env-3ey8js?file=src%2Fapp.component.ts)\n- [v16 with webpack builder](https://stackblitz.com/edit/ngx-env?file=src%2Fapp.component.ts)\n\n#### Quick start\n\n```sh\nng add @ngx-env/builder\n```\n\nEnvironment variables should start with `NG_APP_` prefix, you can define a custom prefix.\n\n```sh\nNG_APP_VERSION=$npm_package_version\nNG_APP_COMMIT=$GITHUB_SHA\nNG_APP_ENABLE_SENTRY=false\n```\n\n```ts\n@Component({\n  selector: \"app-footer\",\n  template: `{{ branch }} - {{ commit }}`,\n  standalone: true,\n})\nexport class MainComponent {\n  branch = import.meta.env.NG_APP_BRANCH_NAME; // Recommended\n  commit = process.env.NG_APP_COMMIT; // Deprecated\n}\n```\n\n```html\n\u003c!-- index.html --\u003e\n\u003chead\u003e\n  \u003ctitle\u003eNgApp on %NG_APP_BRANCH_NAME% - %NG_APP_COMMIT%\u003c/title\u003e\n\u003c/head\u003e\n```\n\nConfiguration options can be passed to `@ngx-env/builder` using `ngxEnv` section in `angular.json` file.\n\n```json\n{\n  \"builder\": \"@ngx-env/builder:application\",\n  \"options\": {\n    \"ngxEnv\": {\n      \"verbose\": true,\n      \"root\": \"../..\",\n      \"prefix\": \"^NG_APP_\"\n    }\n  }\n}\n```\n\nIf you want to update the environment variables at runtime, you can use the `runtime` option.\n\nYou can find the full `@ngx-env/builder` documentation [here](https://github.com/chihab/dotenv-run/tree/main/packages/angular).\n\n### @dotenv-run/webpack\n\n[`@dotenv-run/webpack`](https://www.npmjs.com/package/@dotenv-run/webpack) is a plugin for webpack that can be used to inject environment variables into your applications.\n\n```ts\nimport { DotenvRunPlugin } from \"@dotenv-run/webpack\";\nimport path from \"path\";\n\nconst __dirname = path.resolve();\n\nexport default {\n  entry: \"./src/index.js\",\n  output: {\n    filename: \"main.js\",\n    path: path.resolve(__dirname, \"dist\"),\n  },\n  plugins: [\n    new DotenvRunPlugin(\n      { prefix: \"^API\", verbose: true, root: \"../..\" },\n      __dirname\n    ),\n  ],\n};\n```\n\n### @dotenv-run/rollup\n\n[`@dotenv-run/rollup`](https://www.npmjs.com/package/@dotenv-run/rollup) is a plugin for rollup that can be used to inject environment variables into your applications.\n\n```js\nimport env from \"@dotenv-run/rollup\";\n\nexport default {\n  input: \"src/index.js\",\n  output: {\n    file: \"dist/index.js\",\n  },\n  plugins: [env({ prefix: \"API\", verbose: true, root: \"../../..\" })],\n};\n```\n\n\n[`@dotenv-run/vite`](https://www.npmjs.com/package/@dotenv-run/vite) is a plugin for vite that can be used to inject environment variables into your applications.\n\n```js\nimport env from \"@dotenv-run/vite\";\n\nexport default {\n  envPrefix: 'MY_PREFIX_',\n  envDir: './my-env-directory',\n  plugins: [env()],\n};\n```\n\n## Credits\n\n- [dotenv](https://github.com/motdotla/dotenv)\n\n## License\n\nMIT © [Chihab Otmani](https://twitter.com/chihabotmani)\n","funding_links":[],"categories":["angular","Angular"],"sub_categories":["Builders"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchihab%2Fdotenv-run","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchihab%2Fdotenv-run","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchihab%2Fdotenv-run/lists"}