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/output.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ sort: 5
4
4
contributors:
5
5
- sokra
6
6
- skipjack
7
+
- tomasAlabes
7
8
---
8
9
9
10
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.
@@ -249,7 +250,7 @@ MyLibrary.doSomething(); //if this is window
249
250
```
250
251
251
252
252
-
`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: "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:
262
+
`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:
_Wondering the difference between commonjs and commonjs2? Check [this](https://github.com/webpack/webpack/issues/1114) out (they are pretty much the same)._
271
+
_Wondering the difference between CommonJS and CommonJS2? Check [this](https://github.com/webpack/webpack/issues/1114) out (they are pretty much the same)._
271
272
272
273
273
274
`libraryTarget: "commonjs-module"` - Expose it using the `module.exports` object (`output.library` is ignored), `__esModule` is defined (it's threaded as ES2015 Module in interop mode)
@@ -286,7 +287,7 @@ define([], function() {
286
287
But if you download this script, first you may get a error: `define is not defined`, it’s ok!
287
288
If you are distributing your library with AMD, then your users need to use RequireJS to load it.
288
289
289
-
Now that you have requirejs loaded, you can load your library.
290
+
Now that you have RequireJS loaded, you can load your library.
`libraryTarget: "umd"` - This is a way for your library to work with all module definitions (and where aren't modules at all). It will work with CommonJS, amd AMD as global variable.
320
-
Here to name your module you need the another property:
320
+
`libraryTarget: "umd"` - This is a way for your library to work with all the module definitions (and where aren't modules at all).
321
+
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
+
323
+
In this case, you need the another property to name your module:
321
324
322
325
```javascript
323
326
output: {
@@ -345,6 +348,8 @@ And finally the output is:
345
348
346
349
Module proof library.
347
350
351
+
The dependencies for your library will be defined by the [`externals`](/configuration/externals/) config.
0 commit comments