diff --git a/packages/scripts/scripts/start.js b/packages/scripts/scripts/start.js index 862f11a4d6075..cf29709f3eff1 100644 --- a/packages/scripts/scripts/start.js +++ b/packages/scripts/scripts/start.js @@ -30,11 +30,14 @@ process.env.WP_SRC_DIRECTORY = hasArgInCLI( '--webpack-src-dir' ) ? getArgFromCLI( '--webpack-src-dir' ) : 'src'; -const { status } = spawn( - resolveBin( 'webpack' ), - [ hasArgInCLI( '--hot' ) ? 'serve' : 'watch', ...getWebpackArgs() ], - { - stdio: 'inherit', - } -); +const webpackArgs = getWebpackArgs(); +if ( hasArgInCLI( '--hot' ) ) { + webpackArgs.unshift( 'serve' ); +} else if ( ! hasArgInCLI( '--no-watch' ) ) { + webpackArgs.unshift( 'watch' ); +} + +const { status } = spawn( resolveBin( 'webpack' ), webpackArgs, { + stdio: 'inherit', +} ); process.exit( status === null ? EXIT_ERROR_CODE : status );