# webpack-cli

> CLI for webpack & friends

Latest version **7.2.3** (published 2026-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install webpack-cli
pnpm add webpack-cli
yarn add webpack-cli
bun add webpack-cli
```

Provides the command `webpack-cli`.

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 7.2.3 |
| Published | 2026-08-28 |
| First published | 2015-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20.9.0 |
| Dependencies | 8 |
| Unpacked size | 136 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2616 |
| Maintainers | evilebottnawi, 15000621931, ev1stensberg, __hai, sokra, avivkeller |
| Keywords | webpack, cli, scaffolding, module, bundler, web |

## Links

- npm: https://www.npmjs.com/package/webpack-cli
- Repository: https://github.com/webpack/webpack-cli
- Homepage: https://github.com/webpack/webpack-cli/tree/main/packages/webpack-cli
- Issues: https://github.com/webpack/webpack-cli/issues
- Funding: https://opencollective.com/webpack
- npm.io page: https://npm.io/package/webpack-cli

## Dependencies (8)

- [envinfo](https://npm.io/package/envinfo.md) ^7.21.0
- [rechoir](https://npm.io/package/rechoir.md) ^0.8.0
- [commander](https://npm.io/package/commander.md) ^14.0.3
- [interpret](https://npm.io/package/interpret.md) ^3.1.1
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.6
- [import-local](https://npm.io/package/import-local.md) ^3.2.0
- [webpack-merge](https://npm.io/package/webpack-merge.md) ^6.0.1
- [@discoveryjs/json-ext](https://npm.io/package/@discoveryjs/json-ext.md) ^1.1.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 7.2.3 (latest) — 2026-08-28
- 4.0.0-rc.1 (next) — 2020-10-06
- 4.0.0-beta.9 (beta) — 2020-09-19
- 4.0.0-alpha-5 (4.0.0.0-alpha-5) — 2019-07-08
- 7.2.2 — 2026-07-28
- 7.2.1 — 2026-07-04
- 7.2.0 — 2026-07-04
- 7.1.0 — 2026-06-26
- 7.0.3 — 2026-05-27
- 7.0.2 — 2026-03-17
- 7.0.1 — 2026-03-16
- 7.0.0 — 2026-03-13
- 6.0.1 — 2024-12-20
- 6.0.0 — 2024-12-19
- 5.1.4 — 2023-06-07
- … 119 more at https://npm.io/package/webpack-cli/versions

## README

<div align="center">
    <a href="https://github.com/webpack/webpack-cli">
        <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
    </a>
</div>

# webpack CLI

The official CLI of webpack

## About

webpack CLI provides a flexible set of commands for developers to increase speed when setting up a custom webpack project. As of webpack v4, webpack is not expecting a configuration file, but often developers want to create a more custom webpack configuration based on their use-cases and needs. webpack CLI addresses these needs by providing a set of tools to improve the setup of custom webpack configuration.

## How to install

When you have followed the [Getting Started](https://webpack.js.org/guides/getting-started/) guide of webpack then webpack CLI is already installed!

Otherwise

```bash
npm install --save-dev webpack-cli
```

or

```bash
yarn add webpack-cli --dev
```

## Supported arguments and commands

### Usage

All interactions with webpack-cli are of the form

```bash
npx webpack-cli [command] [options]
```

If no command is specified then `bundle` command is used by default

### Help Usage

To display basic commands and arguments -

```bash
npx webpack-cli --help
```

To display all supported commands and arguments -

```bash
npx webpack-cli --help=verbose
```

or

```bash
npx webpack-cli --help verbose
```

### Available Commands

```
  build|bundle|b [entries...] [options]  Run webpack (default command, can be omitted).
  configtest|t [config-path]             Validate a webpack configuration.
  help|h [command] [option]              Display help for commands and options.
  info|i [options]                       Outputs information about your system.
  serve|server|s [entries...] [options]  Run the webpack dev server and watch for source file changes while serving.
  version|v [options]                    Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
  watch|w [entries...] [options]         Run webpack and watch for files changes.
```

### Available Options

```
Options:
  -c, --config <pathToConfigFile...>     Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js".
  --config-name <name...>                Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations.
  -m, --merge                            Merge two or more configurations using 'webpack-merge'.
  --disable-interpret                    Disable interpret for loading the config file.
  --env <value...>                       Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval".
  --config-node-env <value>              Sets process.env.NODE_ENV to the specified value for access within the configuration.
  --analyze                              It invokes webpack-bundle-analyzer plugin to get bundle information.
  --progress [value]                     Print compilation progress during build.
  -j, --json [pathToJsonFile]            Prints result as JSON or store it in a file.
  --fail-on-warnings                     Stop webpack-cli process with non-zero exit code on warnings from webpack.
  -d, --devtool <value>                  A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
  --no-devtool                           Negative 'devtool' option.
  --entry <value...>                     A module that is loaded upon startup. Only the last one is exported.
  -e, --extends <value...>               Path to the configuration to be extended (only works when using webpack-cli).
  --mode <value>                         Enable production optimizations or development hints.
  --name <value>                         Name of the configuration. Used when loading multiple configurations.
  -o, --output-path <value>              The output directory as **absolute path** (required).
  --stats [value]                        Stats options object or preset name.
  --no-stats                             Negative 'stats' option.
  -t, --target <value...>                Environment to build for. Environment to build for. An array of environments to build for all of them when possible.
  --no-target                            Negative 'target' option.
  -w, --watch                            Enter watch mode, which rebuilds on file change.
  --no-watch                             Negative 'watch' option.
  --watch-options-stdin                  Stop watching when stdin stream has ended.
  --no-watch-options-stdin               Negative 'watch-options-stdin' option.

Global options:
  --color                                Enable colors on console.
  --no-color                             Disable colors on console.
  -v, --version                          Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
  -h, --help [verbose]                   Display help for commands and options.
```

Checkout [`OPTIONS.md`](https://github.com/webpack/webpack-cli/blob/main/OPTIONS.md) to see list of all available options.

## Exit codes and their meanings

| Exit Code | Description                                        |
| --------- | -------------------------------------------------- |
| `0`       | Success                                            |
| `1`       | Errors from webpack                                |
| `2`       | Configuration/options problem or an internal error |

## CLI Environment Variables

| Environment Variable                | Description                                                         |
| ----------------------------------- | ------------------------------------------------------------------- |
| `WEBPACK_CLI_SKIP_IMPORT_LOCAL`     | when `true` it will skip using the local instance of `webpack-cli`. |
| `WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG` | when `true` it will force load the ESM config.                      |
| `WEBPACK_PACKAGE`                   | Use a custom webpack version in CLI.                                |
| `WEBPACK_DEV_SERVER_PACKAGE`        | Use a custom webpack-dev-server version in CLI.                     |
| `WEBPACK_CLI_HELP_WIDTH`            | Use custom width for help output.                                   |

## Configuration Environment Variables

You can use the following environment variables inside your webpack configuration:

| Environment Variable | Description                                  |
| -------------------- | -------------------------------------------- |
| `WEBPACK_SERVE`      | `true` if `serve\|s` is being used.          |
| `WEBPACK_BUILD`      | `true` if `build\|bundle\|b` is being used.  |
| `WEBPACK_WATCH`      | `true` if `--watch\|watch\|w` is being used. |

Checkout [webpack.js.org](https://webpack.js.org/api/cli/) for more detailed documentation of `webpack-cli`.

---
_Source: https://npm.io/package/webpack-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
