@dotenv-run/webpack
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

@dotenv-run/webpack

  • ✅ Load environment variables from the command line API_BASE=/v1/ webpack
  • ✅ Load environment variables from .env files
  • ✅ Expand environment variables API_URL=$API_BASE/users
  • ✅ Define environment variables for a specific environment (e.g. .env.production)
  • ✅ Load priorities of .env.* files (e.g. .env.production > .env)
  • ✅ Hierarchical cascading configuration in monorepo projects (Nx, Turbo, etc.) apps/next-app/.env > apps/.env > .env

Install

npm add @dotenv-run/webpack --save-dev

Usage

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

import { DotenvRunPlugin } from "@dotenv-run/webpack";
import path from "path";

const __dirname = path.resolve();

export default {
  entry: "./src/index.js",
  output: {
    filename: "main.js",
    path: path.resolve(__dirname, "dist"),
  },
  plugins: [
    new DotenvRunPlugin(
      { prefix: "API", verbose: true, root: "../../.." },
      __dirname
    ),
  ],
};

Readme

Keywords

Package Sidebar

Install

npm i @dotenv-run/webpack

Weekly Downloads

9,785

Version

1.5.0

License

ISC

Unpacked Size

8.77 kB

Total Files

10

Last publish

Collaborators

  • chihab