File tree 2 files changed +19
-2
lines changed
packages/react-scripts/scripts
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,16 @@ function printErrors(summary, errors) {
133
133
// Create the production build and print the deployment instructions.
134
134
function build ( previousSizeMap ) {
135
135
console . log ( 'Creating an optimized production build...' ) ;
136
- webpack ( config ) . run ( ( err , stats ) => {
136
+
137
+ var compiler ;
138
+ try {
139
+ compiler = webpack ( config ) ;
140
+ } catch ( err ) {
141
+ printErrors ( 'Failed to compile.' , [ err ] ) ;
142
+ process . exit ( 1 ) ;
143
+ }
144
+
145
+ compiler . run ( ( err , stats ) => {
137
146
if ( err ) {
138
147
printErrors ( 'Failed to compile.' , [ err ] ) ;
139
148
process . exit ( 1 ) ;
Original file line number Diff line number Diff line change @@ -63,7 +63,15 @@ if (isSmokeTest) {
63
63
function setupCompiler ( host , port , protocol ) {
64
64
// "Compiler" is a low-level interface to Webpack.
65
65
// It lets us listen to some events and provide our own custom messages.
66
- compiler = webpack ( config , handleCompile ) ;
66
+ try {
67
+ compiler = webpack ( config , handleCompile ) ;
68
+ } catch ( err ) {
69
+ console . log ( chalk . red ( 'Failed to compile.' ) ) ;
70
+ console . log ( ) ;
71
+ console . log ( err . message || err ) ;
72
+ console . log ( ) ;
73
+ process . exit ( 1 ) ;
74
+ }
67
75
68
76
// "invalid" event fires when you have changed a file, and Webpack is
69
77
// recompiling a bundle. WebpackDevServer takes care to pause serving the
You can’t perform that action at this time.
0 commit comments