webpack progress plugin

This commit is contained in:
afc163 2015-08-19 13:24:51 +08:00
parent d46b790493
commit 9b1bbc855b
2 changed files with 17 additions and 8 deletions

20
nico.js
View File

@ -1,13 +1,26 @@
var path = require('path'); var path = require('path');
var package = require('./package'); var package = require('./package');
var webpack = require('webpack'); var webpack = require('webpack');
var ProgressPlugin = require('webpack/lib/ProgressPlugin');
var inspect = require('util').inspect; var inspect = require('util').inspect;
var Busboy = require('busboy'); var Busboy = require('busboy');
var chalk = require('chalk');
var webpackMiddleware = require('webpack-dev-middleware'); var webpackMiddleware = require('webpack-dev-middleware');
var webpackConfig = require('./webpack.config'); var webpackConfig = require('./webpack.config');
var webpackCompiler = webpack(webpackConfig); var webpackCompiler = webpack(webpackConfig);
var handler; var handler;
webpackCompiler.apply(new ProgressPlugin(function(percentage, msg) {
var stream = process.stderr;
if (stream.isTTY && percentage < 0.71) {
stream.cursorTo(0);
stream.write('📦 ' + chalk.green(parseInt(percentage*100)+ '% ') + msg);
stream.clearLine(1);
} else if (percentage === 1) {
console.log(chalk.green('\nwebpack: bundle build is now finished.'));
}
}));
// {{ settings for nico // {{ settings for nico
exports.site = { exports.site = {
name: package.title, name: package.title,
@ -72,12 +85,7 @@ exports.middlewares = [
aggregateTimeout: 300, aggregateTimeout: 300,
poll: true poll: true
}, },
stats: { quiet: true
hash: false,
cached: false,
cachedAssets: false,
colors: true
}
}); });
try { try {
return handler(req, res, next); return handler(req, res, next);

View File

@ -68,6 +68,8 @@
"babel": "^5.8.12", "babel": "^5.8.12",
"babel-core": "^5.8.12", "babel-core": "^5.8.12",
"babel-loader": "^5.3.2", "babel-loader": "^5.3.2",
"busboy": "~0.2.9",
"chalk": "~1.1.0",
"css-animation": "~1.0.3", "css-animation": "~1.0.3",
"css-loader": "^0.14.1", "css-loader": "^0.14.1",
"eslint": "^1.1.0", "eslint": "^1.1.0",
@ -81,8 +83,7 @@
"nico-jsx": "~0.5.8", "nico-jsx": "~0.5.8",
"precommit-hook": "^1.0.7", "precommit-hook": "^1.0.7",
"webpack": "^1.10.1", "webpack": "^1.10.1",
"webpack-dev-middleware": "^1.2.0", "webpack-dev-middleware": "^1.2.0"
"busboy": "~0.2.9"
}, },
"scripts": { "scripts": {
"babel": "babel components --out-dir lib", "babel": "babel components --out-dir lib",