UNPKG

469 BJavaScriptView Raw
1'use strict';
2
3const nanobus = require('nanobus');
4const weblog = require('webpack-log');
5
6module.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};