File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
packages/react-scripts/scripts Expand file tree Collapse file tree 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) {
133133// Create the production build and print the deployment instructions.
134134function build ( previousSizeMap ) {
135135 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 ) => {
137146 if ( err ) {
138147 printErrors ( 'Failed to compile.' , [ err ] ) ;
139148 process . exit ( 1 ) ;
Original file line number Diff line number Diff line change @@ -63,7 +63,15 @@ if (isSmokeTest) {
6363function setupCompiler ( host , port , protocol ) {
6464 // "Compiler" is a low-level interface to Webpack.
6565 // 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+ }
6775
6876 // "invalid" event fires when you have changed a file, and Webpack is
6977 // recompiling a bundle. WebpackDevServer takes care to pause serving the
You can’t perform that action at this time.
0 commit comments