Skip to content

Commit f468614

Browse files
authoredMay 18, 2023
fix: improve help for some flags
1 parent 2b66643 commit f468614

File tree

8 files changed

+532
-482
lines changed

8 files changed

+532
-482
lines changed
 

‎.cspell.json

+14-12
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,25 @@
1717
"configjs",
1818
"configtest",
1919
"CRLs",
20+
"dbaeumer",
2021
"deserialization",
2122
"discoveryjs",
2223
"dotfolder",
2324
"entrypoint",
2425
"entrypoints",
2526
"envinfo",
2627
"Eren",
28+
"esbenp",
29+
"eslintcache",
2730
"execa",
2831
"Fira",
2932
"gitter",
3033
"Gojou",
3134
"Hisoka",
3235
"Hoshiumi",
3336
"Ichigo",
34-
"IIFE's",
3537
"iife",
38+
"IIFE's",
3639
"Itadori",
3740
"Iwaizumi",
3841
"Jotaro",
@@ -45,13 +48,19 @@
4548
"loglevel",
4649
"Luffy",
4750
"mergeable",
51+
"mfirst",
4852
"Miyuki",
4953
"Mizuhara",
54+
"msecond",
55+
"msuccessfully",
5056
"multicompiler",
5157
"multipleq",
58+
"myvar",
59+
"myval",
5260
"Naruto",
5361
"Neue",
5462
"Nishinoya",
63+
"Nitin",
5564
"nwjs",
5665
"Oikawa",
5766
"pathinfo",
@@ -67,9 +76,11 @@
6776
"Satoru",
6877
"Segoe",
6978
"Shoyo",
79+
"smoketest",
7080
"smoketests",
7181
"sockjs",
7282
"somefile",
83+
"sourcemaps",
7384
"SPDY",
7485
"splitted",
7586
"Statsv",
@@ -82,23 +93,14 @@
8293
"Tobio",
8394
"tsbuildinfo",
8495
"typeahead",
96+
"wagoid",
8597
"webassembly",
8698
"webpackfile",
8799
"Yukihira",
88100
"Yukii",
89101
"Yuuji",
90102
"Zangetsu",
91-
"Zenitsu",
92-
"eslintcache",
93-
"wagoid",
94-
"Nitin",
95-
"smoketest",
96-
"dbaeumer",
97-
"esbenp",
98-
"msuccessfully",
99-
"mfirst",
100-
"msecond",
101-
"sourcemaps"
103+
"Zenitsu"
102104
],
103105
"dictionaries": ["npm", "software-terms"],
104106
"ignorePaths": [

‎.gitattributes

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
*.js text eol=lf
2-
*.ts text eol=lf
1+
* text eol=lf

‎OPTIONS.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Alternative usage to run commands: webpack [command] [options]
55
The build tool for modern web applications.
66
77
Options:
8-
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
9-
--config-name <value...> Name of the configuration to use.
8+
-c, --config <pathToConfigFile...> Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js".
9+
--config-name <name...> Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations.
1010
-m, --merge Merge two or more configurations using 'webpack-merge'.
1111
--disable-interpret Disable interpret for loading the config file.
12-
--env <value...> Environment passed to the configuration when it is a function.
12+
--env <value...> Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval".
1313
--node-env <value> Sets process.env.NODE_ENV to the specified value.
1414
--define-process-env-node-env <value> Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`).
1515
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
1616
--progress [value] Print compilation progress during build.
17-
-j, --json [value] Prints result as JSON or store it in a file.
17+
-j, --json [pathToJsonFile] Prints result as JSON or store it in a file.
1818
--fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack.
1919
-e, --extends <value...> Path to the configuration to be extended (only works when using webpack-cli).
2020
--no-amd Negative 'amd' option.
@@ -1015,7 +1015,7 @@ Commands:
10151015
init|create|new|c|n [generation-path] [options] Initialize a new webpack project.
10161016
loader|l [output-path] [options] Scaffold a loader.
10171017
plugin|p [output-path] [options] Scaffold a plugin.
1018-
serve|server|s [entries...] [options] Run the webpack dev server.
1018+
serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving.
10191019
version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
10201020
watch|w [entries...] [options] Run webpack and watch for files changes.
10211021

‎SERVE-OPTIONS-v4.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
```
22
Usage: webpack serve|server|s [entries...] [options]
33
4-
Run the webpack dev server.
4+
Run the webpack dev server and watch for source file changes while serving.
55
66
Options:
7-
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
8-
--config-name <value...> Name of the configuration to use.
7+
-c, --config <pathToConfigFile...> Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js".
8+
--config-name <name...> Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations.
99
-m, --merge Merge two or more configurations using 'webpack-merge'.
1010
--disable-interpret Disable interpret for loading the config file.
11-
--env <value...> Environment passed to the configuration when it is a function.
11+
--env <value...> Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval".
1212
--node-env <value> Sets process.env.NODE_ENV to the specified value.
1313
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
1414
--progress [value] Print compilation progress during build.
15-
-j, --json [value] Prints result as JSON or store it in a file.
15+
-j, --json [pathToJsonFile] Prints result as JSON or store it in a file.
1616
--fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack.
1717
-e, --extends <value...> Path to the configuration to be extended (only works when using webpack-cli).
1818
-d, --devtool <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
@@ -26,6 +26,8 @@ Options:
2626
--no-stats Negative 'stats' option.
2727
-t, --target <value...> Environment to build for. Environment to build for. An array of environments to build for all of them when possible.
2828
--no-target Negative 'target' option.
29+
-w, --watch Enter watch mode, which rebuilds on file change.
30+
--no-watch Negative 'watch' option.
2931
--watch-options-stdin Stop watching when stdin stream has ended.
3032
--no-watch-options-stdin Negative 'watch-options-stdin' option.
3133
--allowed-hosts <value...> Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').

‎packages/serve/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ServeCommand {
2828
{
2929
name: "serve [entries...]",
3030
alias: ["server", "s"],
31-
description: "Run the webpack dev server.",
31+
description: "Run the webpack dev server and watch for source file changes while serving.",
3232
usage: "[entries...] [options]",
3333
pkg: "@webpack-cli/serve",
3434
dependencies: [WEBPACK_PACKAGE, WEBPACK_DEV_SERVER_PACKAGE],

‎packages/webpack-cli/src/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ interface WebpackCLIStats extends Stats {
109109

110110
type WebpackCLIMainOption = Pick<
111111
WebpackCLIBuiltInOption,
112-
"description" | "defaultValue" | "multiple"
112+
"valueName" | "description" | "defaultValue" | "multiple"
113113
> & {
114114
flags: string;
115115
type: Set<BooleanConstructor | StringConstructor | NumberConstructor>;
@@ -139,6 +139,7 @@ interface WebpackCLIBuiltInFlag {
139139
configs?: Partial<FlagConfig>[];
140140
negative?: boolean;
141141
multiple?: boolean;
142+
valueName?: string;
142143
description: string;
143144
describe?: string;
144145
negatedDescription?: string;

‎packages/webpack-cli/src/webpack-cli.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ class WebpackCLI implements IWebpackCLI {
638638

639639
mainOption = {
640640
flags: option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`,
641+
valueName: option.valueName || "value",
641642
description: option.description || "",
642643
type: mainOptionType,
643644
multiple: option.multiple,
@@ -654,6 +655,7 @@ class WebpackCLI implements IWebpackCLI {
654655
} else {
655656
mainOption = {
656657
flags: option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`,
658+
valueName: option.valueName || "value",
657659
description: option.description || "",
658660
type: option.type
659661
? new Set(Array.isArray(option.type) ? option.type : [option.type])
@@ -673,9 +675,13 @@ class WebpackCLI implements IWebpackCLI {
673675
}
674676

675677
if (mainOption.type.size > 1 && mainOption.type.has(Boolean)) {
676-
mainOption.flags = `${mainOption.flags} [value${mainOption.multiple ? "..." : ""}]`;
678+
mainOption.flags = `${mainOption.flags} [${mainOption.valueName || "value"}${
679+
mainOption.multiple ? "..." : ""
680+
}]`;
677681
} else if (mainOption.type.size > 0 && !mainOption.type.has(Boolean)) {
678-
mainOption.flags = `${mainOption.flags} <value${mainOption.multiple ? "..." : ""}>`;
682+
mainOption.flags = `${mainOption.flags} <${mainOption.valueName || "value"}${
683+
mainOption.multiple ? "..." : ""
684+
}>`;
679685
}
680686

681687
if (mainOption.type.size === 1) {
@@ -808,7 +814,9 @@ class WebpackCLI implements IWebpackCLI {
808814
},
809815
],
810816
multiple: true,
811-
description: "Provide path to a webpack configuration file e.g. ./webpack.config.js.",
817+
valueName: "pathToConfigFile",
818+
description:
819+
'Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js".',
812820
helpLevel: "minimum",
813821
},
814822
{
@@ -819,7 +827,9 @@ class WebpackCLI implements IWebpackCLI {
819827
},
820828
],
821829
multiple: true,
822-
description: "Name of the configuration to use.",
830+
valueName: "name",
831+
description:
832+
"Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations.",
823833
helpLevel: "minimum",
824834
},
825835
{
@@ -890,7 +900,8 @@ class WebpackCLI implements IWebpackCLI {
890900
return previous;
891901
},
892902
multiple: true,
893-
description: "Environment passed to the configuration when it is a function.",
903+
description:
904+
'Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval".',
894905
helpLevel: "minimum",
895906
},
896907
{
@@ -958,6 +969,7 @@ class WebpackCLI implements IWebpackCLI {
958969
},
959970
],
960971
alias: "j",
972+
valueName: "pathToJsonFile",
961973
description: "Prints result as JSON or store it in a file.",
962974
helpLevel: "minimum",
963975
},

‎test/help/__snapshots__/help.test.js.snap.devServer4.webpack5

+485-451
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.