function build(previousFileSizes) {
  console.log('Creating an optimized production build...');

  const compiler = webpack(config);
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      let messages;
      if (err) {
        if (!err.message) {
          return reject(err);
        }

        let errMessage = err.message;

        // Add additional information for postcss errors
        if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
          errMessage +=
            '\nCompileError: Begins at CSS selector ' +
            err['postcssNode'].selector;
        }

        messages = formatWebpackMessages({
          errors: [{ message: errMessage }],
          warnings: []
        });
      } else {
        messages = formatWebpackMessages(
          stats.toJson({ all: false, warnings: true, errors: true })
        );
      }
      if (messages.errors.length) {
        // Only keep the first error. Others are often indicative
        // of the same problem, but confuse the reader with noise.
        if (messages.errors.length > 1) {
          messages.errors.length = 1;
        }
        return reject(new Error(messages.errors.join('\n\n')));
      }

      const resolveArgs = {
        stats,
        previousFileSizes,
        warnings: messages.warnings
      };

      return resolve(resolveArgs);
    });
  });
}
// Create the production build and print the deployment instructions.
Create the production build and print the deployment instructions.
Create the production build and print the deployment instructions .
function build(previousFileSizes) {
  console.log('Creating an optimized production build...');
  const compiler = webpack(config);
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      let messages;
      if (err) {
        if (!err.message) {
          return reject(err);
        }
        let errMessage = err.message;
        if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
          errMessage +=
            '\nCompileError: Begins at CSS selector ' +
            err['postcssNode'].selector;
        }
        messages = formatWebpackMessages({
          errors: [{ message: errMessage }],
          warnings: []
        });
      } else {
        messages = formatWebpackMessages(
          stats.toJson({ all: false, warnings: true, errors: true })
        );
      }
      if (messages.errors.length) {
        if (messages.errors.length > 1) {
          messages.errors.length = 1;
        }
        return reject(new Error(messages.errors.join('\n\n')));
      }
      const resolveArgs = {
        stats,
        previousFileSizes,
        warnings: messages.warnings
      };
      return resolve(resolveArgs);
    });
  });
}
function build ( previousFileSizes ) { console . log ( 'Creating an optimized production build...' ) ; const compiler = webpack ( config ) ; return new Promise ( ( resolve , reject ) => { compiler . run ( ( err , stats ) => { let messages ; if ( err ) { if ( ! err . message ) { return reject ( err ) ; } let errMessage = err . message ; if ( Object . prototype . hasOwnProperty . call ( err , 'postcssNode' ) ) { errMessage += '\nCompileError: Begins at CSS selector ' + err [ 'postcssNode' ] . selector ; } messages = formatWebpackMessages ( { errors : [ { message : errMessage } ] , warnings : [ ] } ) ; } else { messages = formatWebpackMessages ( stats . toJson ( { all : false , warnings : true , errors : true } ) ) ; } if ( messages . errors . length ) { if ( messages . errors . length > 1 ) { messages . errors . length = 1 ; } return reject ( new Error ( messages . errors . join ( '\n\n' ) ) ) ; } const resolveArgs = { stats , previousFileSizes , warnings : messages . warnings } ; return resolve ( resolveArgs ) ; } ) ; } ) ; }
Create the production build and print the deployment instructions.
Create the production build and print the deployment instructions .
// Add additional information for postcss errors // Only keep the first error. Others are often indicative // of the same problem, but confuse the reader with noise.