Skip to content

Commit 1a4b047

Browse files
author
Pavithra K
committed
Docs on Multicompilers
1 parent ec9322f commit 1a4b047

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

content/pluginsapi/compiler.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,25 @@ While it essentially performs the same functionality while watching, there are s
6363

6464
## MultiCompiler
6565

66-
?> Can create child compilers?
66+
This module, MultiCompiler, allows webpack to run multiple configurations in separate compiler.
67+
If the `options` parameter in the webpack's NodeJS api is an array of options, webpack applies separate compilers and calls the `callback` method at the end of each compiler execution.
68+
69+
```javascript
70+
var webpack = require('webpack');
71+
72+
var config1 = {
73+
entry: './index1.js',
74+
output: {filename: 'bundle1.js'}
75+
}
76+
var config2 = {
77+
entry: './index2.js',
78+
output: {filename:'bundle2.js'}
79+
}
80+
81+
webpack([config1, config2], (err, stats) => {
82+
process.stdout.write(stats.toString() + "\n");
83+
})
84+
```
6785

6886
## Event Hooks
6987

content/pluginsapi/tapable.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ However, in addition to this, `Tapable` allows you to have access to the "emitte
1616
* `plugin(name:string, handler:function)` - This allows a custom plugin to register into a **Tapable instance**'s event.
1717
This acts as the same as `on()` of `EventEmitter`, for registering a handler/listener to do something when the signal/event happens.
1818

19-
* `apply(...pluginInstances: (AnyPlugin|function)[])` - `AnyPlugin` should be subclass of [AbstractPlugin](https://github.com/webpack/webpack/blob/master/lib/AbstractPlugin.js), or a class (or object, rare case) has an `apply` method, or just a function with some registration code inside.
19+
* `apply(pluginInstances: (AnyPlugin|function)[])` - `AnyPlugin` should be subclass of [AbstractPlugin](https://github.com/webpack/webpack/blob/master/lib/AbstractPlugin.js), or a class (or object, rare case) has an `apply` method, or just a function with some registration code inside.
2020
This method is just to **apply** plugins' definition, so that the real event listeners can be registered into the **Tapable instance**'s registry.
2121

22-
* `applyPlugins*(name:string, ...)` - The **Tapable instance** can apply all the plugins under a particular hash using these functions.
22+
* `applyPlugins*(name:string, )` - The **Tapable instance** can apply all the plugins under a particular hash using these functions.
2323
These group of method act like `emit()` of `EventEmitter`, to control the event emission meticulously with various strategy for various use cases.
2424

2525
* `mixin(pt: Object)` - a simple method to extend `Tapable`'s prototype as a mixin rather than inheritance.

0 commit comments

Comments
 (0)