Skip to content

structure

benholloway edited this page Mar 15, 2016 · 4 revisions

The webpack-angularity-solution is based on webpack-multi-configurator. As such it has a number of defined builds that we will call modes.

Looking at index.js we can see how the multi configurator is prepared.

...
  .define('common')
    .append(require('./config/common'))
  .define('app')
    .generate(require('./config/app'))
    .append('common')
  .define('release')
    .generate(require('./config/release'))
    .append('common')
  .define('test')
    .append(require('./config/test'))
    .append('common')
  .create;

This gives the following structure:

configurator factory

By default, the webpack-configurator instance is created by a factory function.

The factory function can be customised as discussed below.

generators

For test there is no generator, the factory function simply creates the configurator.

In the case of app and release a custom generator() returns a configurator instance for each composition in the /app directory. The generator is passed the factory function so there is no direct dependency webpack-configurator.

For more information refer to the webpack-multi-configurator documentation on generators.

operations

The append()ed operations follow the generator() and mutate the configurator per the webpack-configurator API.

Where a generator returns multiple configurator instances, each is applied to the operations separately. All app, release, and test additionally apply the operations defined in common.

Any extensibility comes from the addition of further operations to these definitions.

For more information refer to the webpack-multi-configurator documentation on operations.

resolve

Finally all configurators are resolved to yield an Array of plain objects, suitable for Webpack.

If you include several definitions then they will all contribute configurations to this Array.

create

The create() method will construct a new instance that inherits all the preceding definitions.

This method is passed by reference to the user so that the user may amend options, and possibly amend the factory function.

Clone this wiki locally