On this page

Options affecting the output of the compilation. output options tell webpack how to write the compiled files to disk.

Type:string

Add a container for define/require functions in the AMD module.

The filename of asset modules as relative path inside the 'output.path' directory.

Type:boolean

Enable/disable creating async chunks that are loaded on demand.

Add a comment in the UMD wrapper.

Type:boolean

Add charset attribute for script tag.

Specifies the filename template of output files of non-initial chunks on disk. You must not specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.

Type:string | false

The format of chunks (formats included by default are 'array-push' (web/WebWorker), 'commonjs' (node.js), 'module' (ESM), but others might be added by plugins).

Type:string | false

The method of loading chunks (methods included by default are 'jsonp' (web), 'import' (ESM), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins).

Type:string

The global variable used by webpack for loading of chunks.

Type:number

Number of milliseconds before chunk request expires.

Clean the output directory before emit.

Type:boolean

Check if to be emitted file already exists and have the same content before writing to output filesystem.

Type:false | "use-credentials" | "anonymous"

This option enables cross-origin loading of chunks.

Specifies the filename template of non-initial output css files on disk. You must not specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.

Specifies the filename template of output css files on disk. You must not specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.

Similar to output.devtoolModuleFilenameTemplate, but used in the case of duplicate module identifiers.

Filename template string of function for the sources array in a generated SourceMap.

Type:string

Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to output.library if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries.

Type:string[]

List of chunk loading types enabled for use by entry points.

Type:string[]

List of library types enabled for use by entry points.

Type:string[]

List of wasm loading types enabled for use by entry points.

The abilities of the environment where the webpack generated code should run.

Specifies the filename of output files on disk. You must not specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.

Type:string

An expression which is used to address the global object/scope in runtime code.

Type:string

Digest types used for the hash.

Type:number

Number of chars which are used for the hash.

Type:string | typeof Hash

Algorithm used for generation the hash (see node.js crypto package).

Type:string

Any string which is added to the hash to salt it.

Type:string

The filename of the Hot Update Chunks. They are inside the output.path directory.

Type:string

The global variable used by webpack for loading of hot update chunks.

Type:string

The filename of the Hot Update Main File. It is inside the 'output.path' directory.

Generate an HTML file for each non-HTML entrypoint with its JS and CSS output chunks injected. Can be overridden per entry via the entry descriptor html option.

Specifies the filename template of non-initial output html files on disk. You must not specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.

Specifies the filename template of output html files on disk. You must not specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.

Type:boolean

Ignore warnings in the browser.

Type:boolean

Wrap javascript code into IIFE's to avoid leaking into global scope.

Type:string

The name of the native import() function (can be exchanged for a polyfill).

Type:string

The name of the native import.meta object (can be exchanged for a polyfill).

Make the output files a library, exporting the exports of the entry point.

Type:string | string[]

Specify which export should be exposed as library.

Type:string

Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).

Type:boolean

Output javascript files as module source type.

Type:string

The output directory as absolute path (required).

Type:boolean | "verbose"

Include comments with information about the modules.

The 'publicPath' specifies the public URL address of the output files when referenced in a browser.

Type:boolean | "preload" | "prefetch" | "none" | ResourceHintsOptions | HtmlResourceHintWebpackOptions[] | ((context: { compilation: Compilation; defaultHints: (HtmlResourceHintHtmlEntryDependency & { hostChunks: string[] })[]; entryName: string; entrypoint: Entrypoint; hostType: "html" | "js" }) => HtmlResourceHintHtmlEntryDependency[])

Resource-hint (<link rel="prefetch"> / <link rel="preload"> / <link rel="modulepreload"> / <link rel="preconnect">) emission for extracted HTML entries and URL-referenced assets. Accepts the initial-graph shorthand (boolean / "prefetch" / "preload" / "none" / HtmlResourceHint[] / function — equivalent to { initial: <value> }) or the full object form { initial, urlHints, preconnect, modulePreloadPolyfill, manifest }. initial defaults on for ESM output (output.module), where native import() would otherwise waterfall; classic output stays opt-in.

Type:false | "module" | "text/javascript"

This option enables loading async chunks via a custom script type, such as script type="module".

Type:string

The filename of the SourceMaps for the JavaScript files. They are inside the 'output.path' directory.

Type:string

Prefixes every line of the source in the bundle with this string.

Type:boolean

Handles error in module loading correctly at a performance cost. This will handle module error compatible with the EcmaScript Modules spec.

Stability: 0Deprecated
Type:boolean

Handles exceptions in module loading correctly at a performance cost (Deprecated). This will handle module error compatible with the Node.js CommonJS way.

Type:boolean

Emit a runtime check that throws a 'MODULE_NOT_FOUND' error when a required module id is missing from the bundle.

Type:string | true | TrustedTypes

Use a Trusted Types policy to create urls for chunks. 'output.uniqueName' is used a default policy name. Passing a string sets a custom policy name.

Type:boolean

If output.libraryTarget is set to umd and output.library is set, setting this to true will name the AMD module.

Type:string

A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals.

Type:string | false

The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins).

Type:boolean

Fall back to non-streaming WebAssembly instantiation when streaming compilation fails because the server does not serve .wasm files with the application/wasm MIME type.

Type:string

The filename of WebAssembly modules as relative path inside the 'output.path' directory.

Specifies the filename template of non-initial output worker's files on disk. You must not specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.

Type:string | false

The method of loading chunks (methods included by default are 'jsonp' (web), 'import' (ESM), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins).

Type:string

Worker public path. Much like the public path, this sets the location where the worker script file is intended to be found. If not set, webpack will use the publicPath. Don't set this option unless your worker scripts are located at a different path from your other script files.

Type:string | false

The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins).