mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-06 12:52:31 +02:00
fix(v2): force terminate building if client bundle failed (#2345)
* fix(v2): force terminate building if client bundle failed * Use ES6 import so tests pass
This commit is contained in:
parent
5226767caf
commit
c9ace3b7ed
1 changed files with 22 additions and 0 deletions
|
@ -4,6 +4,8 @@
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import chalk from 'chalk';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {Configuration} from 'webpack';
|
import {Configuration} from 'webpack';
|
||||||
import merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
|
@ -30,6 +32,26 @@ export function createClientConfig(props: Props): Configuration {
|
||||||
runtimeChunk: true,
|
runtimeChunk: true,
|
||||||
},
|
},
|
||||||
plugins: [
|
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(),
|
new ChunkAssetPlugin(),
|
||||||
// Show compilation progress bar and build time.
|
// Show compilation progress bar and build time.
|
||||||
new LogPlugin({
|
new LogPlugin({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue