aboutsummaryrefslogtreecommitdiffstats
path: root/test/bundler_smoke_tests/lib/run-webpack.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bundler_smoke_tests/lib/run-webpack.js')
-rw-r--r--test/bundler_smoke_tests/lib/run-webpack.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/bundler_smoke_tests/lib/run-webpack.js b/test/bundler_smoke_tests/lib/run-webpack.js
new file mode 100644
index 000000000..ebbaaecb7
--- /dev/null
+++ b/test/bundler_smoke_tests/lib/run-webpack.js
@@ -0,0 +1,26 @@
+import webpack from "webpack";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const dirname = path.dirname( fileURLToPath( import.meta.url ) );
+const configPath = path.resolve( dirname, "..", "webpack.config.cjs" );
+
+// 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( configPath );
+
+ webpack( config, ( err, stats ) => {
+ if ( err || stats.hasErrors() ) {
+ console.error( "Errors detected during Webpack compilation" );
+ reject( err );
+ return;
+ }
+
+ console.log( "Build completed: Webpack" );
+ resolve();
+ } );
+ } );
+}