Documentation
Contribute
Blog
English
中文
한국어
Search
API
concepts
configuration
guides
loaders
migrate
plugins
Datagrid and Charting for Enterprise Applications
webpack 5
webpack 4
Print Section
Introduction
CLI
Module
Node
Loaders
Plugins
Command Line Interface
Commands
Build
Init
Loader
Plugin
Info
Configtest
Serve
Watch
Flags
Negated Flags
Core Flags
Usage
With configuration file
Without configuration file
Default Configurations
Common Options
help
version
config
config-name
merge
extends
json
Environment Options
env
node-env
config-node-env
Configuration Options
Analyzing Bundle
Progress
Pass CLI arguments to Node.js
Exit codes and their meanings
CLI Environment Variables
WEBPACK_PACKAGE
Troubleshooting
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for ./webpack.config.ts
Node Interface
Installation
webpack()
Compiler Instance
Run
Watching
Close Watching
Invalidate Watching
Stats Object
stats.hasErrors()
stats.hasWarnings()
stats.toJson(options)
stats.toString(options)
MultiCompiler
Error Handling
Custom File Systems
Stats Data
Structure
Asset Objects
Chunk Objects
Module Objects
Entry Objects
Errors and Warnings
webpack-dev-server API
Installation
start
startCallback(callback)
stop
stopCallback(callback)
internalIP(family: "v4" | "v6")
internalIPSync(family: "v4" | "v6")
Hot Module Replacement
Module API
accept
accept (self)
decline
decline (self)
dispose (or addDisposeHandler)
invalidate
removeDisposeHandler
Management API
status
check
apply
addStatusHandler
removeStatusHandler
Loader Interface
Examples
Synchronous Loaders
Asynchronous Loaders
"Raw" Loader
Pitching Loader
The Loader Context
Example for the loader context
this.addContextDependency
this.addDependency
this.addMissingDependency
this.async
this.cacheable
this.callback
this.clearDependencies
this.context
this.data
this.emitError
this.emitFile
this.emitWarning
this.environment
this.fs
this.getOptions(schema)
this.getResolve
this.hot
this.hashDigest
this.hashDigestLength
this.hashFunction
this.hashSalt
this.importModule
this.loaderIndex
this.loadModule
this.loaders
this.mode
this.query
this.request
this.resolve
this.resource
this.resourcePath
this.resourceQuery
this.rootContext
this.sourceMap
this.target
this.utils
this.version
this.webpack
Webpack specific properties
this._compilation
this._compiler
Deprecated context properties
this.debug
this.inputValue
this.minimize
this.value
this._module
Error Reporting
Inline matchResource
Logging
Logger Interface
Examples of how to get and use webpack logger in loaders and plugins
Logger methods
Runtime Logger API
Modules
Module Methods
ES6 (Recommended)
import
export
import()
Dynamic expressions in import()
CommonJS
require
require.resolve
require.cache
require.ensure
AMD
define (with factory)
define (with value)
require (amd-version)
Labeled Modules
export label
require label
Webpack
require.context
require.include
require.resolveWeak
warning
Module Variables
module.loaded (NodeJS)
module.hot (webpack-specific)
module.id (CommonJS)
module.exports (CommonJS)
exports (CommonJS)
global (NodeJS)
__dirname (NodeJS)
import.meta
url
webpack
webpackHot
webpackContext
__filename (NodeJS)
__resourceQuery (webpack-specific)
__webpack_public_path__ (webpack-specific)
__webpack_require__ (webpack-specific)
__webpack_chunk_load__ (webpack-specific)
__webpack_module__ (webpack-specific)
__webpack_module__.id (webpack-specific)
__webpack_modules__ (webpack-specific)
__webpack_hash__ (webpack-specific)
__webpack_get_script_filename__ (webpack-specific)
__non_webpack_require__ (webpack-specific)
__webpack_exports_info__ (webpack-specific)
__webpack_is_included__ (webpack-specific)
__webpack_base_uri__ (webpack-specific)
__webpack_runtime_id__
DEBUG (webpack-specific)
Objects
Compilation Object
compilation object methods
getStats
addModule
getModule
findModule
buildModule
processModuleDependencies
addEntry
rebuildModule
finish
seal
unseal
reportDependencyErrorsAndWarnings
addChunkInGroup
addChunk
assignDepth
getDependencyReference
processDependenciesBlocksForChunkGroups
removeReasonsOfDependencyBlock
patchChunksAfterReasonRemoval
removeChunkFromDependencies
sortItemsWithChunkIds
summarizeDependencies
createHash
createModuleAssets
createChunkAssets
getPath
getPathWithInfo
createChildCompiler
checkConstraints
emitAsset
updateAsset
deleteAsset
getAssets
getAsset
Plugins
Compiler Hooks
Watching
Hooks
environment
afterEnvironment
entryOption
afterPlugins
afterResolvers
initialize
beforeRun
run
watchRun
normalModuleFactory
contextModuleFactory
beforeCompile
compile
thisCompilation
compilation
make
afterCompile
shouldEmit
emit
afterEmit
assetEmitted
done
additionalPass
failed
invalid
watchClose
shutdown
infrastructureLog
log
Compilation Hooks
buildModule
rebuildModule
failedModule
succeedModule
finishModules
finishRebuildingModule
seal
unseal
optimizeDependencies
afterOptimizeDependencies
afterChunks
optimize
optimizeModules
afterOptimizeModules
optimizeChunks
afterOptimizeChunks
optimizeTree
afterOptimizeTree
optimizeChunkModules
afterOptimizeChunkModules
shouldRecord
reviveModules
beforeModuleIds
moduleIds
optimizeModuleIds