W3cubDocs

/webpack 2

Target

webpack can compile for multiple environments or targets. To understand what a target is in detail, read the concepts.

target

string

Tells webpack which environment the application is targeting. The following values are supported via WebpackOptionsApply:

target
Description
target
async-node
Description
Compile for usage in a Node.js-like environment (uses fs and vm to load chunks asynchronously)
target
atom
Description
Alias for electron-main
target
electron
Description
Alias for electron-main
target
electron-main
Description
Compile for Electron for main process.
target
electron-renderer
Description
Compile for Electron for renderer process, providing a target using JsonpTemplatePlugin, FunctionModulePlugin for browser environments and NodeTargetPlugin and ExternalsPlugin for CommonJS and Electron built-in modules.
target
node
Description
Compile for usage in a Node.js-like environment (uses Node.js require to load chunks)
target
node-webkit
Description
Compile for usage in WebKit and uses JSONP for chunk loading. Allows importing of built-in Node.js modules and nw.gui (experimental)
target
web
Description
Compile for usage in a browser-like environment (default)
target
webworker
Description
Compile as WebWorker

For example, when the target is set to "electron", webpack includes multiple electron specific variables. For more information on which templates and externals are used, you can refer to webpack's source code.

© 2012–2016 Tobias Koppers
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/configuration/target/