1 | ;
|
2 |
|
3 | const nanobus = require('nanobus');
|
4 | const weblog = require('webpack-log');
|
5 |
|
6 | module.exports = (options) => {
|
7 | const log = weblog({ name: 'serve', id: 'webpack-serve' });
|
8 | const bus = nanobus();
|
9 |
|
10 | if (typeof options.on === 'object') {
|
11 | for (const event of Object.keys(options.on)) {
|
12 | const fn = options.on[event];
|
13 |
|
14 | if (typeof fn === 'function') {
|
15 | log.info(event, fn);
|
16 | bus.on(event, fn);
|
17 | }
|
18 | }
|
19 | }
|
20 |
|
21 | return bus;
|
22 | };
|