Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(api): add --node-env #4523

Merged
merged 3 commits into from
Feb 3, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/content/api/cli.md
Expand Up @@ -63,6 +63,7 @@ By default webpack ships with the following flags:
| `--color` | boolean | Enable colors on console |
| `--merge, -m` | boolean | Merge two or more configurations using webpack-merge e.g. `-c ./webpack.config.js -c ./webpack.test.config.js` |
| `--env` | string[] | Environment passed to the configuration when it is a function |
| `--node-env` | string | Set process.env.NODE_ENV to the specified value |
snitin315 marked this conversation as resolved.
Show resolved Hide resolved
| `--progress` | boolean, string | Print compilation progress during build |
| `--help` | boolean | Outputs list of supported flags and commands |
| `--output-path, -o` | string | Output location of the file generated by webpack e.g. `./dist` |
Expand Down Expand Up @@ -322,7 +323,7 @@ T> See the [stats data api](/api/stats) to read more about the stats generated h
When the webpack configuration [exports a function](/configuration/configuration-types/#exporting-a-function), an "environment" may be passed to it.

```bash
npx webpack --env production # sets env.production == true
npx webpack --env production # env.production = true
```

The `--env` argument accepts multiple values:
Expand All @@ -336,6 +337,16 @@ The `--env` argument accepts multiple values:

T> See the [environment variables](/guides/environment-variables/) guide for more information on its usage.

### NODE_ENV

you can use `--node-env` option to set `process.env.NODE_ENV`:
snitin315 marked this conversation as resolved.
Show resolved Hide resolved

```bash
webpack-cli --node-env production # process.env.NODE_ENV = 'production'
snitin315 marked this conversation as resolved.
Show resolved Hide resolved
```

T> The `mode` option respect the `--node-env` option if you don't set the `mode` option explicitly using CLI options or in configuration(s), i.e. `--node-env production` set `process.env.NODE_ENV` and `mode` to `'production'`
snitin315 marked this conversation as resolved.
Show resolved Hide resolved

## Configuration Options

| Parameter | Explanation | Input type | Default |
Expand Down