You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/configuration/target.md
+47-14Lines changed: 47 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -9,24 +9,57 @@ contributors:
9
9
- pastelsky
10
10
---
11
11
12
-
webpack can compile for multiple environments or _targets_. To understand what a target is in detail, read [the concepts](/concepts/targets).
12
+
webpack can compile for multiple environments or _targets_. To understand what a `target` is in detail, read through [the targets concept page](/concepts/targets).
13
13
14
14
## `target`
15
15
16
-
`string`
16
+
`string | function(compiler)`
17
17
18
-
Tells webpack which environment the application is targeting. The following values are supported via [`WebpackOptionsApply`](https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js):
18
+
Intructs webpack to target a specific environment.
19
19
20
-
|`target`| Description |
21
-
| ------------- |------------------------|
22
-
|`async-node`| Compile for usage in a Node.js-like environment (uses `fs` and `vm` to load chunks asynchronously) |
23
-
|~~`atom`~~| Alias for `electron-main`|
24
-
|~~`electron`~~| Alias for `electron-main`|
25
-
|`electron-main`| Compile for [Electron](http://electron.atom.io/) for main process. |
26
-
|`electron-renderer`| Compile for [Electron](http://electron.atom.io/) for renderer process, providing a target using `JsonpTemplatePlugin`, `FunctionModulePlugin` for browser environments and `NodeTargetPlugin` and `ExternalsPlugin` for CommonJS and Electron built-in modules. |
27
-
|`node`| Compile for usage in a Node.js-like environment (uses Node.js `require` to load chunks) |
28
-
|`node-webkit`| Compile for usage in WebKit and uses JSONP for chunk loading. Allows importing of built-in Node.js modules and [`nw.gui`](http://docs.nwjs.io/en/latest/) (experimental) |
29
-
|`web`| Compile for usage in a browser-like environment **(default)**|
30
-
|`webworker`| Compile as WebWorker |
20
+
21
+
### `string`
22
+
23
+
The following string values are supported via [`WebpackOptionsApply`](https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js):
24
+
25
+
Option | Description
26
+
--------------------- | -----------------------
27
+
`async-node` | Compile for usage in a Node.js-like environment (uses `fs` and `vm` to load chunks asynchronously)
28
+
~~`atom`~~ | Alias for `electron-main`
29
+
~~`electron`~~ | Alias for `electron-main`
30
+
`electron-main` | Compile for [Electron](http://electron.atom.io/) for main process.
31
+
`electron-renderer` | Compile for [Electron](http://electron.atom.io/) for renderer process, providing a target using `JsonpTemplatePlugin`, `FunctionModulePlugin` for browser environments and `NodeTargetPlugin` and `ExternalsPlugin` for CommonJS and Electron built-in modules.
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 and uses JSONP for chunk loading. Allows importing of built-in Node.js modules and [`nw.gui`](http://docs.nwjs.io/en/latest/) (experimental)
34
+
`web` | Compile for usage in a browser-like environment **(default)**
35
+
`webworker` | Compile as WebWorker
31
36
32
37
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](https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js#L70-L185).
38
+
39
+
40
+
### `function`
41
+
42
+
If a function is passed, then it will be called with the compiler as a parameter. Set it to a function if none of the predefined targets from the list above meet your needs.
43
+
44
+
For example, if you don't want any of the plugins they applied:
0 commit comments