Node.js

Webpack CLI

Webpack CLI commands for JavaScript bundling.

28 commands
Windows MacOS Linux
#bundler #build-tool

Basic Commands

Build with default configuration
webpack
Specify entry point from CLI
webpack --entry ./src/index.js
Set the output directory
webpack --output-path ./dist
Use a custom config file
webpack --config webpack.prod.js
Watch files and rebuild on changes
webpack --watch
Show build progress percentage
webpack --progress

Build Modes

Build with optimizations and minification
webpack --mode production
Build with source maps and no minification
webpack --mode development
Build without any default optimizations
webpack --mode none
Generate full source maps
webpack --devtool source-map
Fast source maps for development
webpack --devtool eval-source-map

Dev Server

Start the webpack dev server
webpack serve
Start dev server on a custom port
webpack serve --port 9000
Start server and open browser
webpack serve --open
Enable hot module replacement
webpack serve --hot
Listen on all network interfaces
webpack serve --host 0.0.0.0
Enable HTTPS on dev server
webpack serve --https

Analysis

Output detailed build statistics
webpack --stats detailed
Export build stats as JSON
webpack --json > stats.json
Capture timing info for each module
webpack --profile
Open bundle analyzer visualization
webpack --analyze

Configuration

Generate a new webpack configuration
webpack init
Pass environment variables to config
webpack --env production --env goal=deploy
Validate a configuration file
webpack configtest webpack.config.js
Merge multiple config files
webpack --merge webpack.common.js webpack.prod.js

Quick Commands

Build the project with production optimizations and minification
webpack --mode production
Start the development server with hot module replacement enabled
webpack serve --hot
Export detailed build statistics as JSON for analysis
webpack --json > stats.json