Skip to content

Commit db514db

Browse files
authored
docs(api): explain usage of WEBPACK_PACKAGE env var (#4871)
* docs(api): explain usage of `WEBPACK_PACKAGE` env var * fix: typo * docs: apply suggestions * docs: fix
1 parent 0f40d4e commit db514db

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/content/api/cli.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,16 +521,40 @@ NODE_OPTIONS="--max-old-space-size=4096 -r /path/to/preload/file.js" webpack
521521

522522
## CLI Environment Variables
523523

524-
| Environment Variable | Description |
525-
| ----------------------------------- | ------------------------------------------------------------------- |
526-
| `WEBPACK_CLI_SKIP_IMPORT_LOCAL` | when `true` it will skip using the local instance of `webpack-cli`. |
527-
| `WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG` | when `true` it will force load the ESM config. |
528-
| `WEBPACK_PACKAGE` | Use a custom webpack version in CLI. |
524+
| Environment Variable | Description |
525+
| ------------------------------------- | ------------------------------------------------------------------- |
526+
| `WEBPACK_CLI_SKIP_IMPORT_LOCAL` | when `true` it will skip using the local instance of `webpack-cli`. |
527+
| `WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG` | when `true` it will force load the ESM config. |
528+
| [`WEBPACK_PACKAGE`](#webpack_package) | Use a custom webpack version in CLI. |
529529

530530
```bash
531531
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG=true npx webpack --config ./webpack.config.esm
532532
```
533533

534+
### WEBPACK_PACKAGE
535+
536+
Use a custom webpack version in CLI. Considering the following content in your `package.json`:
537+
538+
```json
539+
{
540+
"webpack": "^4.0.0",
541+
"webpack-5": "npm:webpack@^5.32.0",
542+
"webpack-cli": "^4.5.0"
543+
}
544+
```
545+
546+
To use `webpack v4.0.0`:
547+
548+
```bash
549+
npx webpack
550+
```
551+
552+
To use `webpack v5.32.0`:
553+
554+
```bash
555+
WEBPACK_PACKAGE=webpack-5 npx webpack
556+
```
557+
534558
## ENV Environment Variables
535559

536560
| Environment Variable | Description |

0 commit comments

Comments
 (0)