Skip to content

feat: add --client-need-client-entry and --client-need-hot-entry #3228

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 55 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,61 @@ Following options are available with `webpack serve`:
Usage: webpack serve|s [entries...] [options]

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.
-d, --devtool <value> Determine source maps to use.
--no-devtool Do not generate source maps.
--entry <value...> The entry point(s) of your application e.g. ./src/main.js.
--mode <value> Defines the mode to pass to webpack.
--name <value> Name of the configuration. Used when loading multiple configurations.
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
--no-stats Disable stats output.
-t, --target <value...> Sets the build target e.g. node.
--no-target Negative 'target' option.
--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.
--setup-exit-signals Close and exit the process on SIGINT and SIGTERM.
--no-setup-exit-signals Do not close and exit the process on SIGNIT and SIGTERM.
--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.
-d, --devtool <value> Determine source maps to use.
--no-devtool Do not generate source maps.
--entry <value...> The entry point(s) of your application e.g. ./src/main.js.
--mode <value> Defines the mode to pass to webpack.
--name <value> Name of the configuration. Used when loading multiple configurations.
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
--no-stats Disable stats output.
-t, --target <value...> Sets the build target e.g. node.
--no-target Negative 'target' option.
--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.
--client-need-client-entry Tell devServer to inject a client entry.
--no-client-need-client-entry Do not tell devServer to inject a client entry.
--client-need-hot-entry Tell devServer to inject a Hot Module Replacement entry.
--no-client-need-hot-entry Do not tell devServer to inject a Hot Module Replacement entry.
--setup-exit-signals Close and exit the process on SIGINT and SIGTERM.
--no-setup-exit-signals Do not close and exit the process on SIGNIT and SIGTERM.
--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.
Expand Down
35 changes: 35 additions & 0 deletions bin/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,41 @@ module.exports = {
delete opts.clientOverlay;
},
},
{
name: 'client-need-client-entry',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need a better name, double client can be confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch I will think about it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

client: {
   appendDefaultEntries: true,
   appendHotEntries: true
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, give me time to think about these options, maybe we need { client: (entry) => { return clientOption; } }, so you will setup hot/client entry for multiple entrypoints

type: Boolean,
configs: [
{
type: 'boolean',
},
],
description: 'Tell devServer to inject a client entry.',
negatedDescription: 'Do not tell devServer to inject a client entry.',
negative: true,
processor(opts) {
opts.client = opts.client || {};
opts.client.needClientEntry = opts.clientNeedClientEntry;
delete opts.clientNeedClientEntry;
},
},
{
name: 'client-need-hot-entry',
type: Boolean,
configs: [
{
type: 'boolean',
},
],
description: 'Tell devServer to inject a Hot Module Replacement entry.',
negatedDescription:
'Do not tell devServer to inject a Hot Module Replacement entry.',
negative: true,
processor(opts) {
opts.client = opts.client || {};
opts.client.needHotEntry = opts.clientNeedHotEntry;
delete opts.clientNeedHotEntry;
},
},
{
name: 'setup-exit-signals',
type: Boolean,
Expand Down
158 changes: 85 additions & 73 deletions test/cli/__snapshots__/cli.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -154,81 +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.
--setup-exit-signals Close and exit the process on SIGINT and SIGTERM.
--no-setup-exit-signals Do not close and exit the process on SIGNIT and
SIGTERM.
--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.
--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.
--client-need-client-entry Tell devServer to inject a client entry.
--no-client-need-client-entry Do not tell devServer to inject a client
entry.
--client-need-hot-entry Tell devServer to inject a Hot Module
Replacement entry.
--no-client-need-hot-entry Do not tell devServer to inject a Hot Module
Replacement entry.
--setup-exit-signals Close and exit the process on SIGINT and
SIGTERM.
--no-setup-exit-signals Do not close and exit the process on SIGNIT
and SIGTERM.
--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
Loading