Skip to content

Commit ffb9619

Browse files
committed
Deduplicate target options and improve descriptions
1 parent 3265cc7 commit ffb9619

File tree

2 files changed

+14
-39
lines changed

2 files changed

+14
-39
lines changed

content/concepts/targets.md

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,12 @@ To set the `target` property, you simply set the target value in your webpack co
1616
**webpack.config.js**
1717

1818
```javascript
19-
const config = {
19+
module.exports = {
2020
target: 'node'
2121
};
22-
23-
module.exports = config;
2422
```
2523

26-
## Options
27-
28-
The following is a list of values you can pass to the `target` property.
29-
30-
* `"async-node"` Compile for usage in a Node.js-like environment (use `fs` and `vm` to load chunks async)
31-
* `"electron-main"` Compile for electron renderer process, provide a target using `JsonpTemplatePlugin`, `FunctionModulePlugin` for browser environment and `NodeTargetPlugin` and `ExternalsPlugin` for commonjs and electron bulit-in modules. *Note: need `webpack` >= 1.12.15.
32-
* `"node"` Compile for usage in a Node.js-like environment (uses Node.js `require` to load chunks)
33-
* `"node-webkit"` Compile for usage in webkit, uses jsonp chunk loading but also supports build in Node.js modules plus require("nw.gui") (experimental)
34-
* `"web"` Compile for usage in a browser-like environment (default)
35-
* `"webworker"` Compile as WebWorker
36-
37-
Each _target_ has a variety of deployment/environment specific additions, support to fit its needs.
38-
39-
For example, when you use the `electron-main` _target_, *webpack* includes multiple `electron-main` specific variables. For more information on which templates and _externals_ are used, you can refer [directly to the webpack source code](https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js#L70-L185).
24+
Each _target_ has a variety of deployment/environment specific additions, support to fit its needs. See what [targets are available](/configuration/target).
4025

4126
?> We should expand on this further. What specifically is included.
4227

content/configuration/target.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,28 @@ contributors:
55
- juangl
66
- sokra
77
- skipjack
8+
- SpaceK33z
89
---
910

10-
?> Compare with [the concept page](/concepts/targets) and determine what goes where.
11+
webpack can compile to multiple environments. We call this _targets_. This page shows what targets are supported. [The concept page](/concepts/targets) explains in greater detail what a target is.
1112

1213
## `target`
1314

1415
`string`
1516

16-
Tell webpack what environment the application is targeting. The following options are supported:
17+
Tell webpack what environment the application is targeting. The following values are supported:
1718

18-
`target: "node"` - Compile for [NodeJS](https://nodejs.org/en/), using `require` to load chunks
19+
* `"async-node"` Compile for usage in a Node.js-like environment (use `fs` and `vm` to load chunks async)
20+
* `"electron"` Compile for [Electron](http://electron.atom.io/) renderer process, provide a target using `JsonpTemplatePlugin`, `FunctionModulePlugin` for browser environment and `NodeTargetPlugin` and `ExternalsPlugin` for CommonJs and Electron built-in modules.
21+
* `"electron-renderer"` - Compile for [Electron](http://electron.atom.io/) for `renderer-process`
22+
* `"node"` Compile for usage in a Node.js-like environment (uses Node.js `require` to load chunks)
23+
* `"node-webkit"` Compile for usage in WebKit and uses jsonp chunk loading. Allows importing of built-in Node.js modules and [`nw.gui`](http://docs.nwjs.io/en/latest/) (experimental)
24+
* `"web"` Compile for usage in a browser-like environment (default)
25+
* `"webworker"` Compile as WebWorker
1926

20-
`target: "node-webkit"` - Compile for [Webkit](https://webkit.org/), using [JSONP](https://sacha.me/articles/jsonp-demystified/) to load chunks
27+
For example, when you use the `"electron"` _target_, *webpack* includes multiple Electron specific variables. For more information on which templates and _externals_ are used, you can refer [directly to the webpack source code](https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js#L70-L185).
2128

22-
`target: "web"` - Compile for usage in a browser
23-
24-
`target: "webworker"` - Compile as a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
25-
26-
27-
T> Allows importing of built-in Node.js modules and [`nw.gui`](http://docs.nwjs.io/en/latest/) (experimental).
28-
29-
`target: "async-node"` - Use `fs` and `vm` to load chunks asynchronously
30-
31-
`target: "electron"` - Compile for [Electron](http://electron.atom.io/) for `main-process`
32-
33-
`target: "electron-main"` - Alias for `target: "electron"`
34-
35-
`target: "electron-renderer"` - Compile for [Electron](http://electron.atom.io/) for `renderer-process`
36-
37-
T> Allows importing of Electron-specific modules.
38-
39-
It defaults to:
29+
The target option defaults to:
4030

4131
```js
4232
target: "web"

0 commit comments

Comments
 (0)