35 lines
846 B
JavaScript
35 lines
846 B
JavaScript
const webpack = require('webpack');
|
|
const formatMessages = require('webpack-format-messages');
|
|
|
|
const debug = require('debug')('truss:task:build');
|
|
|
|
const config = require('../webpack.config')();
|
|
|
|
webpack(config).run((error, stats) => {
|
|
if (error) { return debug(error); }
|
|
|
|
const messages = formatMessages(stats);
|
|
|
|
if (!messages.errors.length && !messages.warnings.length) {
|
|
debug('Compiled successfully!');
|
|
debug(stats.toString({
|
|
chunkModules: true,
|
|
colors: true,
|
|
context: process.cwd(),
|
|
}));
|
|
}
|
|
|
|
if (messages.errors.length) {
|
|
debug('Failed to compile.');
|
|
messages.errors.forEach(e => debug(e));
|
|
return;
|
|
}
|
|
|
|
if (messages.warnings.length) {
|
|
debug('Compiled with warnings.');
|
|
messages.warnings.forEach(w => debug(w));
|
|
}
|
|
});
|
|
|
|
process.on('uncaughtException', (e) => console.error(e));
|