terriajs
Version:
Geospatial data visualization platform.
56 lines (52 loc) • 1.58 kB
JavaScript
const notifier = require("node-notifier");
/**
* Start webpack in watch mode
*/
function watchWebpack(webpack, config, _doneCallback) {
// webpack is passed as a parameter instead of require-in because otherwise, when TerriaJS is npm link'd,
// node will end up loading two copies of webpack. That causes problems with some plugins (e.g. dedupe).
const wp = webpack(config);
wp.hooks.watchRun.tap("NoteStart", function () {
console.log("STARTING INCREMENTAL WEBPACK");
});
wp.watch({}, function (err, stats) {
if (stats) {
// Fairly minimal output for 'gulp watch'.
console.log(
stats.toString({
colors: true,
modules: false,
chunkModules: false,
version: false,
hash: false,
chunks: true,
assets: false
})
);
console.log("DONE INCREMENTAL WEBPACK");
const jsonStats = stats.toJson();
if (err || (jsonStats.errors && jsonStats.errors.length > 0)) {
notifier.notify({
title: "Error building TerriaJS specs",
message: stats.toString({
colors: false,
hash: false,
version: false,
timings: false,
assets: false,
chunks: false,
chunkModules: false,
modules: false,
children: false,
cached: false,
reasons: false,
source: false,
errorDetails: true,
chunkOrigins: false
})
});
}
}
});
}
module.exports = watchWebpack;