-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdisplay.js
49 lines (43 loc) · 1.66 KB
/
display.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const path = require('path');
const webpack = require('webpack');
const displayTool = require('@talentsoft-opensource/widget-display-tool');
const logging = require('./logging');
const webpackConfiguration = require('./webpack.config');
const widgetName = require('./widget.conf.json').Name;
const opn = require('opn');
const logger = logging.defaultLogger;
logger.info('starting webpack watch on widget code...');
let displayToolStarted = false;
const compiler = webpack({ ...webpackConfiguration, mode: 'development' });
compiler.watch(
{
aggregateTimeout: 300,
ignored: 'node_modules',
},
(err, stats) => {
logger.info(stats.toString({
builtAt: true,
entrypoints: false,
modules: false
}));
if (err) {
logger.error(err);
}
if (!displayToolStarted) {
displayToolStarted = true;
const widgetBundlePath = path.resolve('./dist/' + widgetName + '.bundle.js');
const hostmockBundlePath = path.resolve('./dist/hostmock.bundle.js');
const port = 5555;
logger.info("starting the display tool...");
displayTool({
port,
loggerFactory: logging.loggerFactory,
bundleFile: widgetBundlePath,
mockFile: hostmockBundlePath,
});
// this line will open a browser
logger.info("opening a browser to test your widget");
logger.info("if you want to disable this behavior please edit the display.js file");
opn('http://localhost:' + port);
}
})