Skip to content

Commit 7f8be99

Browse files
authored
docs(cli): add --config-node-env option (#7525)
1 parent 35023e3 commit 7f8be99

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/content/api/cli.mdx

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ W> If you want to run webpack using `npx` please make sure you have `webpack-cli
4242

4343
webpack-cli offers a variety of commands to make working with webpack easier. By default webpack ships with
4444

45-
| Command | Usage | Description |
46-
| --------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------- |
47-
| [`build`](#build) | `build\|bundle\|b [entries...] [options]` | Run webpack (default command, can be omitted). |
48-
| [`configtest`](#configtest) | `configtest\|t [config-path]` | Validate a webpack configuration. |
49-
| [`help`](#help) | `help\|h [command] [option]` | Display help for commands and options. |
50-
| [`info`](#info) | `info\|i [options]` | Outputs information about your system. |
51-
| [`serve`](#serve) | `serve\|server\|s [options]` | Run the `webpack-dev-server`. |
52-
| [`version`](#version) | `version\|v [commands...]` | Output the version number of `webpack`, `webpack-cli` and `webpack-dev-server`. |
53-
| [`watch`](#watch) | `watch\|w [entries...] [options]` | Run webpack and watch for files changes. |
45+
| Command | Usage | Description |
46+
| --------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------- |
47+
| [`build`](#build) | `build\|bundle\|b [entries...] [options]` | Run webpack (default command, can be omitted). |
48+
| [`configtest`](#configtest) | `configtest\|t [config-path]` | Validate a webpack configuration. |
49+
| [`help`](#help) | `help\|h [command] [option]` | Display help for commands and options. |
50+
| [`info`](#info) | `info\|i [options]` | Outputs information about your system. |
51+
| [`serve`](#serve) | `serve\|server\|s [options]` | Run the `webpack-dev-server`. |
52+
| [`version`](#version) | `version\|v [commands...]` | Output the version number of `webpack`, `webpack-cli` and `webpack-dev-server`. |
53+
| [`watch`](#watch) | `watch\|w [entries...] [options]` | Run webpack and watch for files changes. |
5454

5555
### Build
5656

@@ -257,31 +257,31 @@ npx webpack watch --mode development
257257

258258
By default webpack ships with the following flags:
259259

260-
| Flag / Alias | Type | Description |
261-
| --------------------------------------------------------------- | --------------- | ------------------------------------------------------------------------- |
262-
| [`--entry`](#entry) | string[] | The entry point(s) of your application e.g. `./src/main.js` |
263-
| [`--config, -c`](#config) | string[] | Provide path to a webpack configuration file e.g. `./webpack.config.js` |
264-
| [`--config-name`](#config-name) | string[] | Name of the configuration to use |
265-
| `--name` | string | Name of the configuration. Used when loading multiple configurations |
266-
| `--color` | boolean | Enable colors on console |
267-
| [`--merge, -m`](#merge) | boolean | Merge two or more configurations using `webpack-merge` |
268-
| [`--env`](#env) | string[] | Environment passed to the configuration when it is a function |
269-
| [`--define-process-env-node-env`](#define-process-env-node-env) | string | Set `process.env.NODE_ENV` to the specified value |
270-
| [`--progress`](#progress) | boolean, string | Print compilation progress during build |
271-
| [`--help`](#help) | boolean | Outputs list of supported flags and commands |
272-
| [`--output-path, -o`](#output-path) | string | Output location of the file generated by webpack e.g. `./dist` |
273-
| `--target, -t` | string[] | Sets the build target |
274-
| `--watch, -w` | boolean | Watch for file changes |
275-
| `--watch-options-stdin` | boolean | Stop watching when stdin stream has ended |
276-
| `--devtool, -d` | string | Controls if and how source maps are generated. |
277-
| [`--json, -j`](#json) | boolean, string | Prints result as JSON or store it in a file |
278-
| `--mode` | string | Defines the mode to pass to webpack |
279-
| [`--version, -v`](#version) | boolean | Get current version |
280-
| `--stats` | boolean, string | It instructs webpack on how to treat the stats |
281-
| `--disable-interpret` | boolean | Disable interpret for loading the config file. |
282-
| `--fail-on-warnings` | boolean | Stop webpack-cli process with non-zero exit code on warnings from webpack |
283-
| [`--analyze`](#analyzing-bundle) | boolean | It invokes `webpack-bundle-analyzer` plugin to get bundle information |
284-
| [`--extends, -e`](#extends) | string[] | Extend an existing configuration |
260+
| Flag / Alias | Type | Description |
261+
| --------------------------------------- | --------------- | ------------------------------------------------------------------------- |
262+
| [`--entry`](#entry) | string[] | The entry point(s) of your application e.g. `./src/main.js` |
263+
| [`--config, -c`](#config) | string[] | Provide path to a webpack configuration file e.g. `./webpack.config.js` |
264+
| [`--config-name`](#config-name) | string[] | Name of the configuration to use |
265+
| `--name` | string | Name of the configuration. Used when loading multiple configurations |
266+
| `--color` | boolean | Enable colors on console |
267+
| [`--merge, -m`](#merge) | boolean | Merge two or more configurations using `webpack-merge` |
268+
| [`--env`](#env) | string[] | Environment passed to the configuration when it is a function |
269+
| [`--config-node-env`](#config-node-env) | string | Set `process.env.NODE_ENV` to the specified value |
270+
| [`--progress`](#progress) | boolean, string | Print compilation progress during build |
271+
| [`--help`](#help) | boolean | Outputs list of supported flags and commands |
272+
| [`--output-path, -o`](#output-path) | string | Output location of the file generated by webpack e.g. `./dist` |
273+
| `--target, -t` | string[] | Sets the build target |
274+
| `--watch, -w` | boolean | Watch for file changes |
275+
| `--watch-options-stdin` | boolean | Stop watching when stdin stream has ended |
276+
| `--devtool, -d` | string | Controls if and how source maps are generated. |
277+
| [`--json, -j`](#json) | boolean, string | Prints result as JSON or store it in a file |
278+
| `--mode` | string | Defines the mode to pass to webpack |
279+
| [`--version, -v`](#version) | boolean | Get current version |
280+
| `--stats` | boolean, string | It instructs webpack on how to treat the stats |
281+
| `--disable-interpret` | boolean | Disable interpret for loading the config file. |
282+
| `--fail-on-warnings` | boolean | Stop webpack-cli process with non-zero exit code on warnings from webpack |
283+
| [`--analyze`](#analyzing-bundle) | boolean | It invokes `webpack-bundle-analyzer` plugin to get bundle information |
284+
| [`--extends, -e`](#extends) | string[] | Extend an existing configuration |
285285

286286
### Negated Flags
287287

@@ -632,25 +632,25 @@ You can use `--node-env` option to set `process.env.NODE_ENV`, which is availabl
632632
npx webpack --node-env production # process.env.NODE_ENV = 'production'
633633
```
634634

635-
W> This option is deprecated and removed in webpack-cli v5 in favor of the `--define-process-env-node-env` option.
635+
W> This option is deprecated in webpack-cli v6 in favor of the `--config-node-env` option.
636636

637-
### define-process-env-node-env
637+
### config-node-env
638638

639-
For `webpack-cli v5+`.
639+
<Badge text="webpack-cli v6.0.0+" />
640640

641641
An alias for [`--node-env`](/api/cli/#node-env) to set `process.env.NODE_ENV`:
642642

643643
```bash
644-
npx webpack --define-process-env-node-env production # process.env.NODE_ENV = 'production'
644+
npx webpack --config-node-env production # process.env.NODE_ENV = 'production'
645645
```
646646

647-
When the `mode` option is not specified in the configuration, you can use the `--define-process-env-node-env` option to set the `mode`. For example, using `--define-process-env-node-env production` will set both `process.env.NODE_ENV` and `mode` to `'production'`.
647+
When the `mode` option is not specified in the configuration, you can use the `--config-node-env` option to set the `mode`. For example, using `--config-node-env production` will set both `process.env.NODE_ENV` and `mode` to `'production'`.
648648

649-
If your configuration exports a function, the value of `--define-process-env-node-env` is assigned to mode after the function returns. This means that `mode` will not be available in the function arguments (`env` and `argv`). However, the value of `--define-process-env-node-env` is accessible as `argv.nodeEnv` within the function and can be used accordingly.
649+
If your configuration exports a function, the value of `--config-node-env` is assigned to mode after the function returns. This means that `mode` will not be available in the function arguments (`env` and `argv`). However, the value of `--config-node-env` is accessible as `argv.nodeEnv` within the function and can be used accordingly.
650650

651651
```javascript
652652
module.exports = (env, argv) => {
653-
console.log(argv.defineProcessEnvNodeEnv); // 'production' if --define-process-env-node-env production is used
653+
console.log(argv.defineProcessEnvNodeEnv); // 'production' if --config-node-env production is used
654654
return {
655655
// your configuration
656656
};

0 commit comments

Comments
 (0)