CLI for webpack and friends - provides comprehensive command-line interface for webpack with configuration, building, serving, and analysis capabilities.
—
Webpack CLI provides a comprehensive command-line interface for webpack operations including building, serving, configuration testing, and system information.
Main webpack CLI commands for different operations.
# Build command (default)
webpack-cli [entry] [options]
# Development server
webpack-cli serve [options]
# System and configuration information
webpack-cli info [options]
# Test configuration
webpack-cli configtest [config-path]
# Help system
webpack-cli help [command]
webpack-cli --help
# Version information
webpack-cli --versionThe default command that runs webpack compilation.
webpack-cli [entry] [options]
# Examples:
webpack-cli # Use default config
webpack-cli ./src/index.js # Specify entry point
webpack-cli --mode production # Set mode
webpack-cli --config webpack.prod.js # Custom config fileCommon Build Options:
# Configuration
--config <path> # Configuration file path
--config-name <name> # Named configuration
--merge # Merge configurations
# Entry and Output
--entry <path> # Entry point
--output-path <path> # Output directory
--output-filename <name> # Output filename pattern
--output-public-path <path> # Public path for assets
# Mode and Environment
--mode <mode> # Development or production mode
--env <env> # Environment variables for config
# Development Options
--watch # Watch for file changes
--watch-options-aggregated-timeout <ms> # Watch debounce timeout
--watch-options-ignored <pattern> # Ignore patterns for watching
# Progress and Output
--progress # Show progress
--json # Output stats as JSON
--stats <preset> # Stats output level
--analyze # Run bundle analyzerDevelopment server integration with webpack-dev-server.
webpack-cli serve [options]
# Examples:
webpack-cli serve # Start dev server
webpack-cli serve --port 3000 # Custom port
webpack-cli serve --host 0.0.0.0 # Custom host
webpack-cli serve --open # Open browserServe Options:
# Server Configuration
--host <host> # Dev server host
--port <port> # Dev server port
--https # Enable HTTPS
--open [target] # Open browser
# Hot Reloading
--hot # Enable hot module replacement
--live-reload # Enable live reload
# Static Files
--static <path> # Serve static files from path
--static-public-path <path> # Public path for static filesSystem and configuration information display.
webpack-cli info [options]
# Examples:
webpack-cli info # Basic system info
webpack-cli info --additional-package react # Include package info
webpack-cli info --output json # JSON output formatInfo Options:
--output <format> # Output format (json, markdown)
--additional-package <name> # Include additional package infoValidate webpack configuration files.
webpack-cli configtest [config-path]
# Examples:
webpack-cli configtest # Test default config
webpack-cli configtest webpack.prod.js # Test specific config
webpack-cli configtest --config-name prod # Test named configOptions available across all commands.
# Help and Version
--help # Show help
--version # Show version
# Verbosity
--silent # Suppress output
--verbose # Verbose output
# Colors
--color # Force color output
--no-color # Disable color outputWebpack configuration options available via CLI flags.
# Optimization
--optimization-minimize # Enable minification
--optimization-concatenate-modules # Enable module concatenation
--optimization-split-chunks # Enable chunk splitting
# Performance
--performance-hints <value> # Performance hints level
--performance-max-entrypoint-size <size> # Max entrypoint size
--performance-max-asset-size <size> # Max asset size
# DevTool
--devtool <type> # Source map type
# Target
--target <target> # Compilation target
# Resolve
--resolve-alias-<key> <value> # Add resolve alias
--resolve-extensions <ext> # Resolve extensionsCLI exit codes for different scenarios.
# Exit codes:
# 0 - Success
# 1 - Webpack compilation errors
# 2 - Configuration/CLI errorsUsage Examples:
# Basic build
webpack-cli
# Production build with custom config
webpack-cli --mode production --config webpack.prod.js
# Watch mode with progress
webpack-cli --watch --progress
# Development server with hot reload
webpack-cli serve --hot --open
# Bundle analysis
webpack-cli --analyze --mode production
# Configuration validation
webpack-cli configtest webpack.prod.js
# System information
webpack-cli info --output jsonInstall with Tessl CLI
npx tessl i tessl/npm-webpack-cli