packages/heisenberg-scripts/scripts/build.js
async function build( previousFileSizes ) {
	console.log( 'Creating an optimized production build...' );

	const filenames = await getFilenames( FILENAMES );
	const webpackConfig = await createWebpackConfig( config( filenames ) );
	const compiler = webpack( webpackConfig );

	return new Promise( ( resolve, reject ) => {
		compiler.run( ( err, stats ) => {
			if ( err ) {
				return reject( err );
			}

			const 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' ) ) );
			}

			if ( process.env.CI && ( typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length ) {
				console.log(
					chalk.yellow( '\nTreating warnings as errors because process.env.CI = true.\nMost CI servers set it automatically.\n' )
				);

				return reject( new Error( messages.warnings.join( '\n\n' ) ) );
			}

			resolve( {
				previousFileSizes,
				stats,
				warnings: messages.warnings,
			} );
		} );
	} );
}
async function build( previousFileSizes ) {
	console.log( 'Creating an optimized production build...' );

	const filenames = await getFilenames( FILENAMES );
	const webpackConfig = await createWebpackConfig( config( filenames ) );
	const compiler = webpack( webpackConfig );

	return new Promise( ( resolve, reject ) => {
		compiler.run( ( err, stats ) => {
			if ( err ) {
				return reject( err );
			}

			const 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' ) ) );
			}

			if ( process.env.CI && ( typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length ) {
				console.log(
					chalk.yellow( '\nTreating warnings as errors because process.env.CI = true.\nMost CI servers set it automatically.\n' )
				);

				return reject( new Error( messages.warnings.join( '\n\n' ) ) );
			}

			resolve( {
				previousFileSizes,
				stats,
				warnings: messages.warnings,
			} );
		} );
	} );
}
async function build ( previousFileSizes ) { console . log ( 'Creating an optimized production build...' ) ; const filenames = await getFilenames ( FILENAMES ) ; const webpackConfig = await createWebpackConfig ( config ( filenames ) ) ; const compiler = webpack ( webpackConfig ) ; return new Promise ( ( resolve , reject ) => { compiler . run ( ( err , stats ) => { if ( err ) { return reject ( err ) ; } const 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' ) ) ) ; } if ( process . env . CI && ( typeof process . env . CI !== 'string' || process . env . CI . toLowerCase ( ) !== 'false' ) && messages . warnings . length ) { console . log ( chalk . yellow ( '\nTreating warnings as errors because process.env.CI = true.\nMost CI servers set it automatically.\n' ) ) ; return reject ( new Error ( messages . warnings . join ( '\n\n' ) ) ) ; } resolve ( { previousFileSizes , stats , warnings : messages . warnings , } ) ; } ) ; } ) ; }
Build script.
Build script .