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
+39-3Lines changed: 39 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -250,7 +250,27 @@ MyLibrary.doSomething(); //if this is window
250
250
```
251
251
252
252
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:
253
+
`libraryTarget: "window"` - When your library is loaded, **the return value of your entry point** will be part `window` object.
254
+
255
+
```javascript
256
+
window["MyLibrary"] = _entry_return_;
257
+
258
+
//your users will use your library like:
259
+
window.MyLibrary.doSomething();
260
+
```
261
+
262
+
263
+
`libraryTarget: "global"` - When your library is loaded, **the return value of your entry point** will be part `global` object.
264
+
265
+
```javascript
266
+
global["MyLibrary"] = _entry_return_;
267
+
268
+
//your users will use your library like:
269
+
global.MyLibrary.doSomething();
270
+
```
271
+
272
+
273
+
`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:
282
+
283
+
`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
342
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
343
323
-
In this case, you need the another property to name your module:
344
+
In this case, you need the `library` property to name your module:
324
345
325
346
```javascript
326
347
output: {
@@ -347,6 +368,21 @@ And finally the output is:
347
368
348
369
Module proof library.
349
370
371
+
372
+
`libraryTarget: "assign"` - Here webpack will blindly generates an implied global.
373
+
374
+
```javascript
375
+
MyLibrary = _entry_return_;
376
+
```
377
+
Be aware that if `MyLibrary` isn't defined earlier your library will be set in global scope.
378
+
379
+
380
+
`libraryTarget: "jsonp"` - This will wrap the return value of your entry point into a jsonp wrapper.
381
+
382
+
```javascript
383
+
MyLibrary( _entry_return_ );
384
+
```
385
+
350
386
The dependencies for your library will be defined by the [`externals`](/configuration/externals/) config.
0 commit comments