function printFileSizes( stats, previousSizeMap ) {
  const assets = stats.toJson().assets
    .filter( asset => /\.(js|css)$/.test( asset.name ))
    .map(( asset ) => {
      const fileContents = fs.readFileSync( `${appBuild}/${asset.name}` );
      const size = gzipSize( fileContents );
      const previousSize = previousSizeMap[removeFileNameHash( asset.name )];
      const difference = getDifferenceLabel( size, previousSize );
      return {
        folder: path.join( outputPath, path.dirname( asset.name )),
        name: path.basename( asset.name ),
        size,
        sizeLabel: filesize( size ) + ( difference ? ` (${difference})` : '' )
      };
    });
  assets.sort(( a, b ) => b.size - a.size );
  const longestSizeLabelLength = Math.max.apply(
    null,
    assets.map( a => stripAnsi( a.sizeLabel ).length ),
  );
  assets.forEach(( asset ) => {
    let sizeLabel = asset.sizeLabel;
    const sizeLength = stripAnsi( sizeLabel ).length;
    if ( sizeLength < longestSizeLabelLength ) {
      const rightPadding = ' '.repeat( longestSizeLabelLength - sizeLength );
      sizeLabel += rightPadding;
    }
    print(
      `  ${sizeLabel}  ${chalk.dim( asset.folder + path.sep )}${chalk.cyan( asset.name )}`,
    );
    print();
  });
}
// Print a detailed summary of build files.
Print a detailed summary of build files.
Print a detailed summary of build files .
function printFileSizes( stats, previousSizeMap ) {
  const assets = stats.toJson().assets
    .filter( asset => /\.(js|css)$/.test( asset.name ))
    .map(( asset ) => {
      const fileContents = fs.readFileSync( `${appBuild}/${asset.name}` );
      const size = gzipSize( fileContents );
      const previousSize = previousSizeMap[removeFileNameHash( asset.name )];
      const difference = getDifferenceLabel( size, previousSize );
      return {
        folder: path.join( outputPath, path.dirname( asset.name )),
        name: path.basename( asset.name ),
        size,
        sizeLabel: filesize( size ) + ( difference ? ` (${difference})` : '' )
      };
    });
  assets.sort(( a, b ) => b.size - a.size );
  const longestSizeLabelLength = Math.max.apply(
    null,
    assets.map( a => stripAnsi( a.sizeLabel ).length ),
  );
  assets.forEach(( asset ) => {
    let sizeLabel = asset.sizeLabel;
    const sizeLength = stripAnsi( sizeLabel ).length;
    if ( sizeLength < longestSizeLabelLength ) {
      const rightPadding = ' '.repeat( longestSizeLabelLength - sizeLength );
      sizeLabel += rightPadding;
    }
    print(
      `  ${sizeLabel}  ${chalk.dim( asset.folder + path.sep )}${chalk.cyan( asset.name )}`,
    );
    print();
  });
}
function printFileSizes ( stats , previousSizeMap ) { const assets = stats . toJson ( ) . assets . filter ( asset => / \.(js|css)$ / . test ( asset . name ) ) . map ( ( asset ) => { const fileContents = fs . readFileSync ( ` ${ appBuild } ${ asset . name } ` ) ; const size = gzipSize ( fileContents ) ; const previousSize = previousSizeMap [ removeFileNameHash ( asset . name ) ] ; const difference = getDifferenceLabel ( size , previousSize ) ; return { folder : path . join ( outputPath , path . dirname ( asset . name ) ) , name : path . basename ( asset . name ) , size , sizeLabel : filesize ( size ) + ( difference ? ` ${ difference } ` : '' ) } ; } ) ; assets . sort ( ( a , b ) => b . size - a . size ) ; const longestSizeLabelLength = Math . max . apply ( null , assets . map ( a => stripAnsi ( a . sizeLabel ) . length ) , ) ; assets . forEach ( ( asset ) => { let sizeLabel = asset . sizeLabel ; const sizeLength = stripAnsi ( sizeLabel ) . length ; if ( sizeLength < longestSizeLabelLength ) { const rightPadding = ' ' . repeat ( longestSizeLabelLength - sizeLength ) ; sizeLabel += rightPadding ; } print ( ` ${ sizeLabel } ${ chalk . dim ( asset . folder + path . sep ) } ${ chalk . cyan ( asset . name ) } ` , ) ; print ( ) ; } ) ; }
Print a detailed summary of build files.
Print a detailed summary of build files .