Skip to content

Commit

Permalink
feat: add more static option related cli flags (#3238)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed May 1, 2021
1 parent 2752902 commit 469e558
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 142 deletions.
67 changes: 67 additions & 0 deletions bin/cli-flags.js
Expand Up @@ -37,6 +37,73 @@ module.exports = {
multiple: true,
negative: true,
},
{
name: 'static-directory',
type: String,
configs: [
{
type: 'string',
},
],
description: 'Directory for static contents.',
processor(opts) {
opts.static = opts.static || {};
opts.static.directory = opts.staticDirectory;
delete opts.staticDirectory;
},
},
{
name: 'static-public-path',
type: String,
configs: [
{
type: 'string',
},
],
description:
'The bundled files will be available in the browser under this path.',
multiple: true,
processor(opts) {
opts.static = opts.static || {};
opts.static.publicPath = opts.staticPublicPath;
delete opts.staticPublicPath;
},
},
{
name: 'static-serve-index',
type: Boolean,
configs: [
{
type: 'boolean',
},
],
description: 'Tells dev-server to use serveIndex middleware.',
negatedDescription:
'Do not tell dev-server to use serveIndex middleware.',
negative: true,
processor(opts) {
opts.static = opts.static || {};
opts.static.serveIndex = opts.staticServeIndex;
delete opts.staticServeIndex;
},
},
{
name: 'static-watch',
type: Boolean,
configs: [
{
type: 'boolean',
},
],
description: 'Watch for files in static content directory.',
negatedDescription: 'Do not watch for files in static content directory.',
negative: true,
processor(opts) {
opts.static = opts.static || {};
opts.static.watch = opts.staticWatch;
delete opts.staticWatch;
},
},
{
name: 'live-reload',
type: Boolean,
Expand Down
155 changes: 85 additions & 70 deletions test/cli/__snapshots__/cli.test.js.snap.webpack4
Expand Up @@ -154,78 +154,93 @@ exports[`CLI should generate correct cli flags 1`] = `
Run the webpack dev server.

Options:
-c, --config <value...> Provide path to a webpack configuration file e.g.
./webpack.config.js.
--config-name <value...> Name of the configuration to use.
-m, --merge Merge two or more configurations using
'webpack-merge'.
--env <value...> Environment passed to the configuration when it is
a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--progress [value] Print compilation progress during build.
-j, --json [value] Prints result as JSON or store it in a file.
--entry <value...> The entry point(s) of your application e.g.
./src/main.js.
-o, --output-path <value> Output location of the file generated by webpack
e.g. ./dist/.
-t, --target <value> Sets the build target e.g. node.
-d, --devtool <value> Determine source maps to use.
--mode <value> Defines the mode to pass to webpack.
--name <value> Name of the configuration. Used when loading
multiple configurations.
--stats [value] It instructs webpack on how to treat the stats
e.g. verbose.
--no-stats Disable stats output.
--watch-options-stdin Stop watching when stdin stream has ended.
--no-watch-options-stdin Do not stop watching when stdin stream has ended.
--host <value> The hostname/ip address the server will bind to.
--port <value> The port server will listen to.
--static [value...] A directory to serve static content from.
--no-static Negative 'static' option.
--live-reload Enables live reloading on changing files.
--no-live-reload Disables live reloading on changing files.
--https Use HTTPS protocol.
--no-https Do not use HTTPS protocol.
--http2 Use HTTP/2, must be used with HTTPS.
--no-http2 Do not use HTTP/2.
--bonjour Broadcasts the server via ZeroConf networking on
start.
--no-bonjour Do not broadcast the server via ZeroConf
networking on start.
--client-progress Print compilation progress in percentage in the
browser.
--no-client-progress Do not print compilation progress in percentage in
the browser.
--client-overlay Show a full-screen overlay in the browser when
there are compiler errors or warnings.
--no-client-overlay Do not show a full-screen overlay in the browser
when there are compiler errors or warnings.
--open [value...] Open the default browser.
--no-open Do not open the default browser.
--open-app <value> Open specified browser.
--open-target [value...] Open specified route in browser.
--no-open-target Do not open specified route in browser.
--client-logging <value> Log level in the browser (none, error, warn, info,
log, verbose).
--history-api-fallback Fallback to /index.html for Single Page
Applications.
--no-history-api-fallback Do not fallback to /index.html for Single Page
Applications.
--compress Enable gzip compression.
--no-compress Disable gzip compression.
--public <value> The public hostname/ip address of the server.
--firewall [value...] Enable firewall or set hosts that are allowed to
access the dev server.
--no-firewall Disable firewall.
--watch-files <value...> Watch static files for file changes.
-c, --config <value...> Provide path to a webpack configuration file
e.g. ./webpack.config.js.
--config-name <value...> Name of the configuration to use.
-m, --merge Merge two or more configurations using
'webpack-merge'.
--env <value...> Environment passed to the configuration when
it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified
value.
--progress [value] Print compilation progress during build.
-j, --json [value] Prints result as JSON or store it in a file.
--entry <value...> The entry point(s) of your application e.g.
./src/main.js.
-o, --output-path <value> Output location of the file generated by
webpack e.g. ./dist/.
-t, --target <value> Sets the build target e.g. node.
-d, --devtool <value> Determine source maps to use.
--mode <value> Defines the mode to pass to webpack.
--name <value> Name of the configuration. Used when loading
multiple configurations.
--stats [value] It instructs webpack on how to treat the
stats e.g. verbose.
--no-stats Disable stats output.
--watch-options-stdin Stop watching when stdin stream has ended.
--no-watch-options-stdin Do not stop watching when stdin stream has
ended.
--host <value> The hostname/ip address the server will bind
to.
--port <value> The port server will listen to.
--static [value...] A directory to serve static content from.
--no-static Negative 'static' option.
--static-directory <value> Directory for static contents.
--static-public-path <value...> The bundled files will be available in the
browser under this path.
--static-serve-index Tells dev-server to use serveIndex
middleware.
--no-static-serve-index Do not tell dev-server to use serveIndex
middleware.
--static-watch Watch for files in static content directory.
--no-static-watch Do not watch for files in static content
directory.
--live-reload Enables live reloading on changing files.
--no-live-reload Disables live reloading on changing files.
--https Use HTTPS protocol.
--no-https Do not use HTTPS protocol.
--http2 Use HTTP/2, must be used with HTTPS.
--no-http2 Do not use HTTP/2.
--bonjour Broadcasts the server via ZeroConf
networking on start.
--no-bonjour Do not broadcast the server via ZeroConf
networking on start.
--client-progress Print compilation progress in percentage in
the browser.
--no-client-progress Do not print compilation progress in
percentage in the browser.
--client-overlay Show a full-screen overlay in the browser
when there are compiler errors or warnings.
--no-client-overlay Do not show a full-screen overlay in the
browser when there are compiler errors or
warnings.
--open [value...] Open the default browser.
--no-open Do not open the default browser.
--open-app <value> Open specified browser.
--open-target [value...] Open specified route in browser.
--no-open-target Do not open specified route in browser.
--client-logging <value> Log level in the browser (none, error, warn,
info, log, verbose).
--history-api-fallback Fallback to /index.html for Single Page
Applications.
--no-history-api-fallback Do not fallback to /index.html for Single
Page Applications.
--compress Enable gzip compression.
--no-compress Disable gzip compression.
--public <value> The public hostname/ip address of the
server.
--firewall [value...] Enable firewall or set hosts that are
allowed to access the dev server.
--no-firewall Disable firewall.
--watch-files <value...> Watch static files for file changes.

Global options:
--color Enable colors on console.
--no-color Disable colors on console.
-v, --version Output the version number of 'webpack',
'webpack-cli' and 'webpack-dev-server' and
commands.
-h, --help [verbose] Display help for commands and options.
--color Enable colors on console.
--no-color Disable colors on console.
-v, --version Output the version number of 'webpack',
'webpack-cli' and 'webpack-dev-server' and
commands.
-h, --help [verbose] Display help for commands and options.

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

Expand Down

0 comments on commit 469e558

Please sign in to comment.