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 Feb 29, 2020
1 parent c171609 commit 5e3582b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/docusaurus/src/webpack/client.ts
Expand Up @@ -7,6 +7,7 @@
import path from 'path';
import {Configuration} from 'webpack';
import merge from 'webpack-merge';
import chalk = require('chalk');

import {Props} from '@docusaurus/types';
import {createBaseConfig} from './base';
Expand All @@ -30,6 +31,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 5e3582b

Please sign in to comment.