Skip to content

Commit 469e558

Browse files
authored
feat: add more static option related cli flags (#3238)
1 parent 2752902 commit 469e558

File tree

4 files changed

+312
-142
lines changed

4 files changed

+312
-142
lines changed

bin/cli-flags.js

+67
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,73 @@ module.exports = {
3737
multiple: true,
3838
negative: true,
3939
},
40+
{
41+
name: 'static-directory',
42+
type: String,
43+
configs: [
44+
{
45+
type: 'string',
46+
},
47+
],
48+
description: 'Directory for static contents.',
49+
processor(opts) {
50+
opts.static = opts.static || {};
51+
opts.static.directory = opts.staticDirectory;
52+
delete opts.staticDirectory;
53+
},
54+
},
55+
{
56+
name: 'static-public-path',
57+
type: String,
58+
configs: [
59+
{
60+
type: 'string',
61+
},
62+
],
63+
description:
64+
'The bundled files will be available in the browser under this path.',
65+
multiple: true,
66+
processor(opts) {
67+
opts.static = opts.static || {};
68+
opts.static.publicPath = opts.staticPublicPath;
69+
delete opts.staticPublicPath;
70+
},
71+
},
72+
{
73+
name: 'static-serve-index',
74+
type: Boolean,
75+
configs: [
76+
{
77+
type: 'boolean',
78+
},
79+
],
80+
description: 'Tells dev-server to use serveIndex middleware.',
81+
negatedDescription:
82+
'Do not tell dev-server to use serveIndex middleware.',
83+
negative: true,
84+
processor(opts) {
85+
opts.static = opts.static || {};
86+
opts.static.serveIndex = opts.staticServeIndex;
87+
delete opts.staticServeIndex;
88+
},
89+
},
90+
{
91+
name: 'static-watch',
92+
type: Boolean,
93+
configs: [
94+
{
95+
type: 'boolean',
96+
},
97+
],
98+
description: 'Watch for files in static content directory.',
99+
negatedDescription: 'Do not watch for files in static content directory.',
100+
negative: true,
101+
processor(opts) {
102+
opts.static = opts.static || {};
103+
opts.static.watch = opts.staticWatch;
104+
delete opts.staticWatch;
105+
},
106+
},
40107
{
41108
name: 'live-reload',
42109
type: Boolean,

test/cli/__snapshots__/cli.test.js.snap.webpack4

+85-70
Original file line numberDiff line numberDiff line change
@@ -154,78 +154,93 @@ exports[`CLI should generate correct cli flags 1`] = `
154154
Run the webpack dev server.
155155

156156
Options:
157-
-c, --config <value...> Provide path to a webpack configuration file e.g.
158-
./webpack.config.js.
159-
--config-name <value...> Name of the configuration to use.
160-
-m, --merge Merge two or more configurations using
161-
'webpack-merge'.
162-
--env <value...> Environment passed to the configuration when it is
163-
a function.
164-
--node-env <value> Sets process.env.NODE_ENV to the specified value.
165-
--progress [value] Print compilation progress during build.
166-
-j, --json [value] Prints result as JSON or store it in a file.
167-
--entry <value...> The entry point(s) of your application e.g.
168-
./src/main.js.
169-
-o, --output-path <value> Output location of the file generated by webpack
170-
e.g. ./dist/.
171-
-t, --target <value> Sets the build target e.g. node.
172-
-d, --devtool <value> Determine source maps to use.
173-
--mode <value> Defines the mode to pass to webpack.
174-
--name <value> Name of the configuration. Used when loading
175-
multiple configurations.
176-
--stats [value] It instructs webpack on how to treat the stats
177-
e.g. verbose.
178-
--no-stats Disable stats output.
179-
--watch-options-stdin Stop watching when stdin stream has ended.
180-
--no-watch-options-stdin Do not stop watching when stdin stream has ended.
181-
--host <value> The hostname/ip address the server will bind to.
182-
--port <value> The port server will listen to.
183-
--static [value...] A directory to serve static content from.
184-
--no-static Negative 'static' option.
185-
--live-reload Enables live reloading on changing files.
186-
--no-live-reload Disables live reloading on changing files.
187-
--https Use HTTPS protocol.
188-
--no-https Do not use HTTPS protocol.
189-
--http2 Use HTTP/2, must be used with HTTPS.
190-
--no-http2 Do not use HTTP/2.
191-
--bonjour Broadcasts the server via ZeroConf networking on
192-
start.
193-
--no-bonjour Do not broadcast the server via ZeroConf
194-
networking on start.
195-
--client-progress Print compilation progress in percentage in the
196-
browser.
197-
--no-client-progress Do not print compilation progress in percentage in
198-
the browser.
199-
--client-overlay Show a full-screen overlay in the browser when
200-
there are compiler errors or warnings.
201-
--no-client-overlay Do not show a full-screen overlay in the browser
202-
when there are compiler errors or warnings.
203-
--open [value...] Open the default browser.
204-
--no-open Do not open the default browser.
205-
--open-app <value> Open specified browser.
206-
--open-target [value...] Open specified route in browser.
207-
--no-open-target Do not open specified route in browser.
208-
--client-logging <value> Log level in the browser (none, error, warn, info,
209-
log, verbose).
210-
--history-api-fallback Fallback to /index.html for Single Page
211-
Applications.
212-
--no-history-api-fallback Do not fallback to /index.html for Single Page
213-
Applications.
214-
--compress Enable gzip compression.
215-
--no-compress Disable gzip compression.
216-
--public <value> The public hostname/ip address of the server.
217-
--firewall [value...] Enable firewall or set hosts that are allowed to
218-
access the dev server.
219-
--no-firewall Disable firewall.
220-
--watch-files <value...> Watch static files for file changes.
157+
-c, --config <value...> Provide path to a webpack configuration file
158+
e.g. ./webpack.config.js.
159+
--config-name <value...> Name of the configuration to use.
160+
-m, --merge Merge two or more configurations using
161+
'webpack-merge'.
162+
--env <value...> Environment passed to the configuration when
163+
it is a function.
164+
--node-env <value> Sets process.env.NODE_ENV to the specified
165+
value.
166+
--progress [value] Print compilation progress during build.
167+
-j, --json [value] Prints result as JSON or store it in a file.
168+
--entry <value...> The entry point(s) of your application e.g.
169+
./src/main.js.
170+
-o, --output-path <value> Output location of the file generated by
171+
webpack e.g. ./dist/.
172+
-t, --target <value> Sets the build target e.g. node.
173+
-d, --devtool <value> Determine source maps to use.
174+
--mode <value> Defines the mode to pass to webpack.
175+
--name <value> Name of the configuration. Used when loading
176+
multiple configurations.
177+
--stats [value] It instructs webpack on how to treat the
178+
stats e.g. verbose.
179+
--no-stats Disable stats output.
180+
--watch-options-stdin Stop watching when stdin stream has ended.
181+
--no-watch-options-stdin Do not stop watching when stdin stream has
182+
ended.
183+
--host <value> The hostname/ip address the server will bind
184+
to.
185+
--port <value> The port server will listen to.
186+
--static [value...] A directory to serve static content from.
187+
--no-static Negative 'static' option.
188+
--static-directory <value> Directory for static contents.
189+
--static-public-path <value...> The bundled files will be available in the
190+
browser under this path.
191+
--static-serve-index Tells dev-server to use serveIndex
192+
middleware.
193+
--no-static-serve-index Do not tell dev-server to use serveIndex
194+
middleware.
195+
--static-watch Watch for files in static content directory.
196+
--no-static-watch Do not watch for files in static content
197+
directory.
198+
--live-reload Enables live reloading on changing files.
199+
--no-live-reload Disables live reloading on changing files.
200+
--https Use HTTPS protocol.
201+
--no-https Do not use HTTPS protocol.
202+
--http2 Use HTTP/2, must be used with HTTPS.
203+
--no-http2 Do not use HTTP/2.
204+
--bonjour Broadcasts the server via ZeroConf
205+
networking on start.
206+
--no-bonjour Do not broadcast the server via ZeroConf
207+
networking on start.
208+
--client-progress Print compilation progress in percentage in
209+
the browser.
210+
--no-client-progress Do not print compilation progress in
211+
percentage in the browser.
212+
--client-overlay Show a full-screen overlay in the browser
213+
when there are compiler errors or warnings.
214+
--no-client-overlay Do not show a full-screen overlay in the
215+
browser when there are compiler errors or
216+
warnings.
217+
--open [value...] Open the default browser.
218+
--no-open Do not open the default browser.
219+
--open-app <value> Open specified browser.
220+
--open-target [value...] Open specified route in browser.
221+
--no-open-target Do not open specified route in browser.
222+
--client-logging <value> Log level in the browser (none, error, warn,
223+
info, log, verbose).
224+
--history-api-fallback Fallback to /index.html for Single Page
225+
Applications.
226+
--no-history-api-fallback Do not fallback to /index.html for Single
227+
Page Applications.
228+
--compress Enable gzip compression.
229+
--no-compress Disable gzip compression.
230+
--public <value> The public hostname/ip address of the
231+
server.
232+
--firewall [value...] Enable firewall or set hosts that are
233+
allowed to access the dev server.
234+
--no-firewall Disable firewall.
235+
--watch-files <value...> Watch static files for file changes.
221236

222237
Global options:
223-
--color Enable colors on console.
224-
--no-color Disable colors on console.
225-
-v, --version Output the version number of 'webpack',
226-
'webpack-cli' and 'webpack-dev-server' and
227-
commands.
228-
-h, --help [verbose] Display help for commands and options.
238+
--color Enable colors on console.
239+
--no-color Disable colors on console.
240+
-v, --version Output the version number of 'webpack',
241+
'webpack-cli' and 'webpack-dev-server' and
242+
commands.
243+
-h, --help [verbose] Display help for commands and options.
229244

230245
To see list of all supported commands and options run 'webpack --help=verbose'.
231246

0 commit comments

Comments
 (0)