async function getWebpackSizes() {
  await fse.mkdirp(path.join(__dirname, 'build'));

  const configPath = path.join(__dirname, 'webpack.config.js');
  const statsPath = path.join(__dirname, 'build', 'stats.json');
  await exec(`webpack --config ${configPath} --json > ${statsPath}`);

  const stats = await fse.readJSON(statsPath);
  const assets = new Map(stats.assets.map(asset => [asset.name, asset]));

  return Object.entries(stats.assetsByChunkName).map(([chunkName, assetName]) => {
    const parsedSize = assets.get(assetName).size;
    const gzipSize = assets.get(`${assetName}.gz`).size;
    return [chunkName, { parsed: parsedSize, gzip: gzipSize }];
  });
}
async function getWebpackSizes() {
  await fse.mkdirp(path.join(__dirname, 'build'));

  const configPath = path.join(__dirname, 'webpack.config.js');
  const statsPath = path.join(__dirname, 'build', 'stats.json');
  await exec(`webpack --config ${configPath} --json > ${statsPath}`);

  const stats = await fse.readJSON(statsPath);
  const assets = new Map(stats.assets.map(asset => [asset.name, asset]));

  return Object.entries(stats.assetsByChunkName).map(([chunkName, assetName]) => {
    const parsedSize = assets.get(assetName).size;
    const gzipSize = assets.get(`${assetName}.gz`).size;
    return [chunkName, { parsed: parsedSize, gzip: gzipSize }];
  });
}
async function getWebpackSizes ( ) { await fse . mkdirp ( path . join ( __dirname , 'build' ) ) ; const configPath = path . join ( __dirname , 'webpack.config.js' ) ; const statsPath = path . join ( __dirname , 'build' , 'stats.json' ) ; await exec ( ` ${ configPath } ${ statsPath } ` ) ; const stats = await fse . readJSON ( statsPath ) ; const assets = new Map ( stats . assets . map ( asset => [ asset . name , asset ] ) ) ; return Object . entries ( stats . assetsByChunkName ) . map ( ( [ chunkName , assetName ] ) => { const parsedSize = assets . get ( assetName ) . size ; const gzipSize = assets . get ( ` ${ assetName } ` ) . size ; return [ chunkName , { parsed : parsedSize , gzip : gzipSize } ] ; } ) ; }
creates size snapshot for every bundle that built with webpack
creates size snapshot for every bundle that built with webpack
Get webpack sizes