package
CLI for webpack & friends
npm install webpack-cliGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
The official CLI of webpack
webpack CLI provides a flexible set of commands for developers to increase speed when setting up a custom webpack project. As of webpack v4, webpack is not expecting a configuration file, but often developers want to create a more custom webpack configuration based on their use-cases and needs. webpack CLI addresses these needs by providing a set of tools to improve the setup of custom webpack configuration.
When you have followed the Getting Started guide of webpack then webpack CLI is already installed!
Otherwise
npm install --save-dev webpack-clior
yarn add webpack-cli --devAll interactions with webpack-cli are of the form
npx webpack-cli [command] [options]If no command is specified then bundle command is used by default
To display basic commands and arguments -
npx webpack-cli --helpTo display all supported commands and arguments -
npx webpack-cli --help=verboseor
npx webpack-cli --help verbose build|bundle|b [entries...] [options] Run webpack (default command, can be omitted).
complete [shell] Generate shell completion scripts.
configtest|t [config-path] Validate a webpack configuration.
help|h [command] [option] Display help for commands and options.
info|i [options] Outputs information about your system.
serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving.
version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
watch|w [entries...] [options] Run webpack and watch for files changes.Options:
-c, --config <pathToConfigFile...> Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js".
--config-name <name...> Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations.
-m, --merge Merge two or more configurations using 'webpack-merge'.
--disable-interpret Disable interpret for loading the config file.
--env <value...> Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval".
--config-node-env <value> Sets process.env.NODE_ENV to the specified value for access within the configuration.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [pathToJsonFile] Prints result as JSON or store it in a file.
--fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack.
-d, --devtool <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
-e, --extends <value...> Path to the configuration to be extended (only works when using webpack-cli).
--mode <value> Enable production optimizations or development hints.
--name <value> Name of the configuration. Used when loading multiple configurations.
-o, --output-path <value> The output directory as **absolute path** (required).
--stats [value] Stats options object or preset name.
Checkout OPTIONS.md to see list of all available options.
| Exit Code | Description |
|---|---|
0 | Success |
1 | Errors from webpack |
2 | Configuration/options problem or an internal error |
| Environment Variable | Description |
|---|---|
WEBPACK_CLI_SKIP_IMPORT_LOCAL | when true it will skip using the local instance of webpack-cli. |
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG | when true it will force load the ESM config. |
WEBPACK_PACKAGE | Use a custom webpack version in CLI. |
WEBPACK_DEV_SERVER_PACKAGE | Use a custom webpack-dev-server version in CLI. |
WEBPACK_CLI_HELP_WIDTH | Use custom width for help output. |
You can use the following environment variables inside your webpack configuration:
| Environment Variable | Description |
|---|---|
WEBPACK_SERVE | true if serve|s is being used. |
WEBPACK_BUILD | true if build|bundle|b is being used. |
WEBPACK_WATCH | true if --watch|watch|w is being used. |
Checkout webpack.js.org for more detailed documentation of webpack-cli.
15000621931
784487301@qq.com
Estimated unpacked size across 13 packages.
852.3 kB
Includes dependencies.
6 direct · 1 outdated
^7.21.0
7.21.0
^1.0.0
1.0.0
^14.0.3
15.1.0
^3.1.1
3.1.1
^6.0.1
6.0.1
^1.1.0
1.1.0