Skip to content

Commit

Permalink
Merge pull request #6 from denis-ok/ahrefs-handle-webpack-compilation…
Browse files Browse the repository at this point in the history
…-errors

Handle webpack compilation errors
  • Loading branch information
denis-ok authored Sep 26, 2022
2 parents 915e7d1 + 20ba455 commit b38f0ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
28 changes: 21 additions & 7 deletions commands/reshowcase
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,26 @@ const compiler = webpack({
});

if (isBuild) {
console.log("Building reshowcase bundle...");
compiler.run((err, _result) => {
console.log("Building Reshowcase bundle...");
compiler.run((err, stats) => {
// https://webpack.js.org/api/node/#error-handling
if (err) {
console.error(err);
console.error("Build failed. Webpack fatal errors:\n", err);
process.exit(1);
} else {
console.log("Build finished.");
const info = stats.toJson();
if (stats.hasErrors && info.errors.length > 0) {
console.error(
"Build failed. Webpack complilation errors:\n",
info.errors
);
process.exit(1);
} else {
console.log(
stats.toString({ assets: true, chunks: true, colors: true })
);
console.log("Reshowcase build finished successfully.");
}
}
});
} else {
Expand All @@ -155,16 +169,16 @@ if (isBuild) {
...(config.devServer || {}),
});

['SIGINT', 'SIGTERM'].forEach((signal) => {
["SIGINT", "SIGTERM"].forEach((signal) => {
process.on(signal, () => {
if (server) {
server.close(() => {
process.exit();
})
});
} else {
process.exit();
}
})
});
});

if (config.devServer && config.devServer.socket) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ahrefs/reshowcase",
"version": "5.2.1",
"version": "5.2.2",
"description": "> A tool to create demos for your ReScript React components",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit b38f0ab

Please sign in to comment.