aboutsummaryrefslogtreecommitdiffstats
path: root/test/bundler_smoke_tests/lib/run-webpack.js
blob: 3f3b7a8663228fd0a09b14ce50d2356e09f8f847 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import webpack from "webpack";

// See https://webpack.js.org/api/node/#webpack
export async function runWebpack() {
	return new Promise( async( resolve, reject ) => {
		console.log( "Running Webpack" );

		const { default: config } = await import( "../webpack.config.cjs" );

		webpack( config, ( err, stats ) => {
			if ( err || stats.hasErrors() ) {
				console.error( "Errors detected during Webpack compilation" );
				reject( err );
				return;
			}

			console.log( "Build completed: Webpack" );
			resolve();
		} );
	} );
}