$ show nuxt-community/dotenv-module
This repository is `@nuxtjs/dotenv`, a small Nuxt.js (v2) build-time module that reads a `.env` file, parses it with the `dotenv` library, and injects the variables into Nuxt's `this.options.env`. Nuxt then exposes those values to the application through `process.env` and `context.env`. The module supports custom filenames, custom paths, an allowlist via the `only` option, and optional merging of system environment variables via `systemvars`. It deliberately does not override environment values already defined in `nuxt.config.js`, and it warns instead of crashing when no `.env` file is present. Architecturally this is a tiny npm library, not an application or data pipeline: the core is a single Nuxt module function in `lib/module.js` plus a `consola`-based logger in `lib/logger.js`. It is invoked during Nuxt builds and has no CLI, web server, or long-running process. The test suite uses `@nuxtjs/module-test-utils` to boot fixture Nuxt applications and assert on rendered HTML, covering basic loading, custom file names, custom paths, missing files, and the `only` allowlist behavior. The code is clean, well-tested, and easy to understand, but the surrounding ecosystem has moved on. Nuxt 2 is end-of-life, and the README itself recommends migrating to Nuxt's built-in runtime config. Dependencies such as `dotenv@^8.2.0` and Nuxt 2 edge are old, and the project is effectively in maintenance limbo despite occasional repository activity.
The LLM identified 1 files worth highlighting for reuse:
Core Nuxt module function: reads a `.env` file with `fs.accessSync`/`readFileSync`, parses it with `dotenv`, optionally merges system env vars, and injects allowlisted keys into `this.options.env` only when they are not already set. It demonstrates clean option merging (defaults, top-level `dotenv` config, then module options), graceful missing-file handling, and explicit preservation of pre-existing configuration. The module is self-contained enough to serve as a reference implementation for any Nuxt 2 build-time env/config injection module.