Link Search Menu Expand Document

Output

Summary

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.

API

output.libraryTarget

  • default: string = 'var'

  • Configure how the library will be exposed.

  • Please note that this option works in conjunction with the value assigned to output.library

Expose a Variable

These options assign the return value of the entry point (e.g. whatever the entry point exported) to the name provided by output.library at whatever scope the bundle was included at.

libraryTarget: 'var' - (default) When your library is loaded, the return value of your entry point will be assigned to a variable:

var MyLibrary = _entry_return_;

// In a separate script...
MyLibrary.doSomething();
  • When using this option, an empty output.library will result in no assignment.

Concepts

libraryTarget

CommonJs

commonjs2

commonjs mean pure CommonJs commonjs2 also includes the module.exports stuff.o