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/index.md
+13-6Lines changed: 13 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ contributors:
8
8
- bondz
9
9
- sricc
10
10
- terinjokes
11
+
- mattce
11
12
---
12
13
13
14
webpack is fed via a configuration object. It is passed in one of two ways depending on how you are using webpack: through the terminal or via Node.js. All the available configuration options are specified below.
Copy file name to clipboardExpand all lines: content/configuration/output.md
+40-3Lines changed: 40 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ contributors:
5
5
- sokra
6
6
- skipjack
7
7
- tomasAlabes
8
+
- mattce
8
9
---
9
10
10
11
The top-level `output` key contains set of options instructing webpack on how and where it should output your bundles, assets and anything else you bundle or load with webpack.
@@ -250,7 +251,27 @@ MyLibrary.doSomething(); //if this is window
250
251
```
251
252
252
253
253
-
`libraryTarget: "commonjs"` - When your library is loaded, the return value of your entry point will be part of the exports object. As the name implies, this is used in CommonJS environments:
254
+
`libraryTarget: "window"` - When your library is loaded, **the return value of your entry point** will be part `window` object.
255
+
256
+
```javascript
257
+
window["MyLibrary"] = _entry_return_;
258
+
259
+
//your users will use your library like:
260
+
window.MyLibrary.doSomething();
261
+
```
262
+
263
+
264
+
`libraryTarget: "global"` - When your library is loaded, **the return value of your entry point** will be part `global` object.
265
+
266
+
```javascript
267
+
global["MyLibrary"] = _entry_return_;
268
+
269
+
//your users will use your library like:
270
+
global.MyLibrary.doSomething();
271
+
```
272
+
273
+
274
+
`libraryTarget: "commonjs"` - When your library is loaded, **the return value of your entry point** will be part of the exports object. As the name implies, this is used in CommonJS environments:
`libraryTarget: "commonjs2"` - When your library is loaded, the return value of your entry point will be part of the exports object. As the name implies, this is used in CommonJS environments:
283
+
284
+
`libraryTarget: "commonjs2"` - When your library is loaded, **the return value of your entry point** will be part of the exports object. As the name implies, this is used in CommonJS environments:
`libraryTarget: "umd"` - This is a way for your library to work with all the module definitions (and where aren't modules at all).
321
343
It will work with CommonJS, AMD and as global variable. You can check the [UMD Repository](https://github.com/umdjs/umd) to know more about it.
322
344
323
-
In this case, you need the another property to name your module:
345
+
In this case, you need the `library` property to name your module:
324
346
325
347
```javascript
326
348
output: {
@@ -347,6 +369,21 @@ And finally the output is:
347
369
348
370
Module proof library.
349
371
372
+
373
+
`libraryTarget: "assign"` - Here webpack will blindly generate an implied global.
374
+
375
+
```javascript
376
+
MyLibrary = _entry_return_;
377
+
```
378
+
Be aware that if `MyLibrary` isn't defined earlier your library will be set in global scope.
379
+
380
+
381
+
`libraryTarget: "jsonp"` - This will wrap the return value of your entry point into a jsonp wrapper.
382
+
383
+
```javascript
384
+
MyLibrary( _entry_return_ );
385
+
```
386
+
350
387
The dependencies for your library will be defined by the [`externals`](/configuration/externals/) config.
0 commit comments