( previousFileSizes )
| 130 | |
| 131 | // Create the production build and print the deployment instructions. |
| 132 | function build( previousFileSizes ) { |
| 133 | // We used to support resolving modules according to `NODE_PATH`. |
| 134 | // This now has been deprecated in favor of jsconfig/tsconfig.json |
| 135 | // This lets you use absolute paths in imports inside large monorepos: |
| 136 | if ( process.env.NODE_PATH ) { |
| 137 | console.log( |
| 138 | chalk.yellow( |
| 139 | // eslint-disable-next-line max-len |
| 140 | "Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.", |
| 141 | ), |
| 142 | ); |
| 143 | console.log(); |
| 144 | } |
| 145 | |
| 146 | console.log( "Creating an optimized production build..." ); |
| 147 | |
| 148 | const compiler = webpack( config ); |
| 149 | return new Promise( ( resolve, reject ) => { |
| 150 | compiler.run( ( err, stats ) => { |
| 151 | let messages; |
| 152 | if ( err ) { |
| 153 | if ( ! err.message ) { |
| 154 | return reject( err ); |
| 155 | } |
| 156 | |
| 157 | let errMessage = err.message; |
| 158 | |
| 159 | // Add additional information for postcss errors |
| 160 | if ( Object.prototype.hasOwnProperty.call( err, "postcssNode" ) ) { |
| 161 | errMessage += |
| 162 | "\nCompileError: Begins at CSS selector " + |
| 163 | err.postcssNode.selector; |
| 164 | } |
| 165 | |
| 166 | messages = formatWebpackMessages( { |
| 167 | errors: [ errMessage ], |
| 168 | warnings: [], |
| 169 | } ); |
| 170 | } else { |
| 171 | messages = formatWebpackMessages( |
| 172 | stats.toJson( { all: false, warnings: true, errors: true } ), |
| 173 | ); |
| 174 | } |
| 175 | if ( messages.errors.length ) { |
| 176 | // Only keep the first error. Others are often indicative |
| 177 | // Of the same problem, but confuse the reader with noise. |
| 178 | if ( messages.errors.length > 1 ) { |
| 179 | messages.errors.length = 1; |
| 180 | } |
| 181 | return reject( new Error( messages.errors.join( "\n\n" ) ) ); |
| 182 | } |
| 183 | if ( |
| 184 | process.env.CI && |
| 185 | ( typeof process.env.CI !== "string" || |
| 186 | process.env.CI.toLowerCase() !== "false" ) && |
| 187 | messages.warnings.length |
| 188 | ) { |
| 189 | console.log( |
no outgoing calls
no test coverage detected