-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
35 lines (28 loc) · 901 Bytes
/
index.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
'use strict';
var webpack = require('webpack');
var path = require('path');
var chalk = require('chalk');
var progress = require('progress');
var objectAssign = require('object-assign');
var messageTemplate = [':bar', chalk.green(':percent'), ':msg'].join(' ');
var progressOptions = {
complete: chalk.bgGreen(' '),
incomplete: chalk.bgWhite(' '),
width: 40,
total: 100,
clear: false
};
function SimpleProgressPlugin(options) {
if (!process.stderr.isTTY) {
return function () {};
}
if (options) {
messageTemplate = options.messageTemplate || messageTemplate;
progressOptions = objectAssign(progressOptions, options.progressOptions);
}
var progressBar = new progress(messageTemplate, progressOptions);
return new webpack.ProgressPlugin(function(percentage, msg) {
progressBar.update(percentage, { msg: msg });
});
}
module.exports = SimpleProgressPlugin;