Installation
Basic Configuration
webpack.config.js
Dev Server Options
Port number for the dev server.Default:
8080Host to use for the dev server.Default:
'localhost'Enable Hot Module Replacement.Default:
trueOpen the browser after server starts.Default:
falseEnable gzip compression for everything served.Default:
trueStatic Files
Configure serving static files.
Proxy
Proxy API requests to another server.
target: Target hostpathRewrite: Rewrite target’s URL pathchangeOrigin: Change the origin header to the target URLsecure: Verify SSL certificatesws: Proxy WebSocketsbypass: Function to bypass proxy conditionally
Headers and CORS
Add custom headers to all responses.
Whitelist hosts that are allowed to access the dev server.
HTTPS
Enable HTTPS.
History API Fallback
Serve index.html for 404s (useful for SPAs).
Watch Options
Watch files and trigger full page reload.
Live Reload
Enable live reload (disable if only using HMR).Default:
trueClient Configuration
Configure client-side behavior.
Advanced Options
Development Middleware
Development Middleware
Options for webpack-dev-middleware.
Server Setup
Server Setup
WebSocket
WebSocket
WebSocket server type.
Common Patterns
Basic SPA Setup
webpack.config.js
API Proxy Configuration
webpack.config.js
HTTPS Development
webpack.config.js
Static Assets and Public Path
webpack.config.js
Custom Headers and CORS
webpack.config.js
Development with WebSockets
webpack.config.js
Error Overlay Configuration
webpack.config.js
Running the Dev Server
package.json