Skip to content

Commit

Permalink
fix(v2): force terminate building if client bundle failed
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Mar 6, 2020
1 parent c171609 commit 0e81395
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/docusaurus/src/webpack/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import chalk = require('chalk');
import path from 'path';
import {Configuration} from 'webpack';
import merge from 'webpack-merge';
Expand All @@ -30,6 +32,26 @@ export function createClientConfig(props: Props): Configuration {
runtimeChunk: true,
},
plugins: [
// Plugin to force terminate building if errors happened in the client bundle
{
apply: compiler => {
compiler.hooks.done.tap('client:done', stats => {
if (stats.hasErrors()) {
console.log(
chalk.red(
'Client bundle compiled with errors therefore further build is impossible.',
),
);

stats.toJson('errors-only').errors.forEach(e => {
console.error(e);
});

process.exit(1);
}
});
},
},
new ChunkAssetPlugin(),
// Show compilation progress bar and build time.
new LogPlugin({
Expand Down

0 comments on commit 0e81395

Please sign in to comment.