Socket
Socket
Sign inDemoInstall

webpack-cli

Package Overview
Dependencies
120
Maintainers
3
Versions
123
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    webpack-cli

CLI for webpack & friends


Version published
Weekly downloads
7.3M
increased by1.26%
Maintainers
3
Install size
1.02 MB
Created
Weekly downloads
 

Package description

What is webpack-cli?

The webpack-cli npm package provides a command-line interface for the webpack bundler, which allows developers to interact with webpack and its features directly from the command line. It enables tasks such as creating a new webpack project, managing configurations, running the development server, and more.

What are webpack-cli's main functionalities?

Initializing a new webpack project

This command sets up a new webpack project by generating a default configuration file. It can also install webpack and related dependencies if they are not already installed.

webpack-cli init

Generating a configuration file

Generates a webpack configuration file based on the user's preferences. It can be used to quickly scaffold a new configuration or to update an existing one.

webpack-cli generate

Running a webpack build

Executes the webpack build process, which bundles the source files according to the webpack configuration. This is typically used for production builds.

webpack-cli build

Starting a development server

Starts the webpack development server, which provides a live reloading environment for development purposes. It watches for file changes and automatically recompiles the project.

webpack-cli serve

Running webpack in watch mode

Runs webpack in watch mode, where it watches for file changes and recompiles the project as necessary. This is useful during development to see changes reflected immediately.

webpack-cli watch

Other packages similar to webpack-cli

Changelog

Source

5.0.0 (2022-11-17)

Bug Fixes

  • improve description of the --disable-interpret option (#3364) (bdb7e20)
  • remove the redundant utils export (#3343) (a9ce5d0)
  • respect NODE_PATH env variable (#3411) (83d1f58)
  • show all CLI specific flags in the minimum help output (#3354) (35843e8)

Features

  • failOnWarnings option (#3317) (c48c848)
  • update commander to v9 (#3460) (6621c02)
  • added the --define-process-env-node-env option
  • update interpret to v3 and rechoir to v0.8
  • add an option for preventing interpret (#3329) (c737383)

BREAKING CHANGES

  • the minimum supported webpack version is v5.0.0 (#3342) (b1af0dc), closes #3342
  • webpack-cli no longer supports webpack v4, the minimum supported version is webpack v5.0.0
  • webpack-cli no longer supports webpack-dev-server v3, the minimum supported version is webpack-dev-server v4.0.0
  • remove the migrate command (#3291) (56b43e4), closes #3291
  • remove the --prefetch option in favor the PrefetchPlugin plugin
  • remove the --node-env option in favor --define-process-env-node-env
  • remove the --hot option in favor of directly using the HotModuleReplacement plugin (only for build command, for serve it will work)
  • the behavior logic of the --entry option has been changed - previously it replaced your entries, now the option adds a specified entry, if you want to return the previous behavior please use webpack --entry-reset --entry './src/my-entry.js'

Readme

Source

webpack CLI

The official CLI of webpack

About

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.

How to install

When you have followed the Getting Started guide of webpack then webpack CLI is already installed!

Otherwise

npm install --save-dev webpack-cli

or

yarn add webpack-cli --dev

Supported arguments and commands

Usage

All 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

Help Usage

To display basic commands and arguments -

npx webpack-cli --help

To display all supported commands and arguments -

npx webpack-cli --help=verbose

or

npx webpack-cli --help verbose

Available Commands

  build|bundle|b [entries...] [options]                 Run webpack (default command, can be omitted).
  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.
  init|create|new|c|n [generation-path] [options]       Initialize a new webpack project.
  loader|l [output-path] [options]                      Scaffold a loader.
  plugin|p [output-path] [options]                      Scaffold a plugin.
  serve|server|s [entries...] [options]                 Run the webpack dev server.
  version|v [commands...]                               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.

Available 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'.
  --disable-interpret                              Disable interpret for loading the config file.
  --env <value...>                                 Environment passed to the configuration when it is a function.
  --define-process-env-node-env <value>            Sets process.env.NODE_ENV to the specified value.
  --analyze                                        It invokes webpack-bundle-analyzer plugin to get bundle information.
  --progress [value]                               Print compilation progress during build.
  -j, --json [value]                               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.
  --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.
  --no-stats                                       Negative 'stats' option.
  -t, --target <value...>                          Environment to build for. Environment to build for. An array of environments to build for all of them when possible.
  --no-target                                      Negative 'target' option.
  -w, --watch                                      Enter watch mode, which rebuilds on file change.
  --no-watch                                       Negative 'watch' option.
  --watch-options-stdin                            Stop watching when stdin stream has ended.
  --no-watch-options-stdin                         Negative 'watch-options-stdin' option.

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.

Checkout OPTIONS.md to see list of all available options.

Exit codes and their meanings

Exit CodeDescription
0Success
1Errors from webpack
2Configuration/options problem or an internal error

CLI Environment Variables

Environment VariableDescription
WEBPACK_CLI_SKIP_IMPORT_LOCALwhen true it will skip using the local instance of webpack-cli.
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIGwhen true it will force load the ESM config.
WEBPACK_PACKAGEUse a custom webpack version in CLI.
WEBPACK_DEV_SERVER_PACKAGEUse a custom webpack-dev-server version in CLI.
WEBPACK_CLI_HELP_WIDTHUse custom width for help output.

Configuration Environment Variables

You can use the following environment variables inside your webpack configuration:

Environment VariableDescription
WEBPACK_SERVEtrue if serve|s is being used.
WEBPACK_BUILDtrue if build|bundle|b is being used.
WEBPACK_WATCHtrue if --watch|watch|w is being used.

Checkout webpack.js.org for more detailed documentation of webpack-cli.

Keywords

FAQs

Last updated on 17 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc