@@ -65,7 +65,7 @@ function spawnTestProcess(processPath, argv, options = {}) {
6565 NODE_ENV : 'development' ,
6666 ...options . env ,
6767 } ;
68- const successRegex = new RegExp ( options . successMessage || 'compiled successfully ' , 'i' ) ;
68+ const successRegex = new RegExp ( options . successMessage || 'webpack compilation complete. ' , 'i' ) ;
6969
7070 return new Promise ( ( resolve , reject ) => {
7171 const instance = spawn ( processPath , argv , { cwd, env } ) ;
@@ -95,7 +95,10 @@ function spawnTestProcess(processPath, argv, options = {}) {
9595 */
9696 function handleStderr ( data ) {
9797 const message = data . toString ( ) ;
98- process . stderr . write ( message ) ;
98+
99+ if ( __DEBUG__ ) {
100+ process . stderr . write ( message ) ;
101+ }
99102 }
100103
101104 instance . stdout . on ( 'data' , handleStdout ) ;
@@ -119,35 +122,45 @@ function spawnTestProcess(processPath, argv, options = {}) {
119122
120123/**
121124 * @param {number } port
122- * @param {string } directory
125+ * @param {Object } dirs
126+ * @param {string } dirs.public
127+ * @param {string } dirs.root
128+ * @param {string } dirs.src
123129 * @param {SpawnOptions } [options]
124130 * @returns {Promise<import('child_process').ChildProcess | void> }
125131 */
126- function spawnWebpackServe ( port , directory , options = { } ) {
132+ function spawnWebpackServe ( port , dirs , options = { } ) {
127133 const webpackBin = getPackageExecutable ( 'webpack-cli' ) ;
134+
135+ const NODE_OPTIONS = [
136+ // This requires a script to alias `webpack` and `webpack-cli` -
137+ // both v4 and v5 is installed side by side,
138+ // so we have to ensure that they resolve to the `legacy` variant.
139+ WEBPACK_VERSION === 4 && `--require "${ require . resolve ( './aliasLegacyWebpack' ) } "` ,
140+ // This requires a script to alias `webpack-dev-server` for Node.js v10.x -
141+ // both v3 and v4 is installed side by side,
142+ // so we have to ensure that it resolves to the `legacy` variant.
143+ WDS_VERSION === 3 && `--require "${ require . resolve ( './aliasLegacyWebpackDevServer' ) } "` ,
144+ ]
145+ . filter ( Boolean )
146+ . join ( ' ' ) ;
147+
128148 return spawnTestProcess (
129149 webpackBin ,
130150 [
131151 'serve' ,
152+ '--no-color' ,
132153 '--config' ,
133- path . resolve ( directory , 'webpack.config.js' ) ,
134- '--content-base' ,
135- directory ,
154+ path . join ( dirs . root , 'webpack.config.js' ) ,
155+ WDS_VERSION === 3 ? '--content-base' : '--static-directory ',
156+ dirs . public ,
136157 '--hot' ,
137158 '--port' ,
138159 port ,
139160 ] ,
140161 {
141162 ...options ,
142- env : {
143- ...options . env ,
144- ...( WEBPACK_VERSION === 4 && {
145- // This requires a script to alias `webpack` and `webpack-cli` -
146- // both v4 and v5 is installed side by side,
147- // so we have to ensure that they resolve to the `legacy` variant.
148- NODE_OPTIONS : `--require "${ require . resolve ( './aliasLegacyWebpack' ) } "` ,
149- } ) ,
150- } ,
163+ env : { ...options . env , ...( NODE_OPTIONS && { NODE_OPTIONS } ) } ,
151164 }
152165 ) ;
153166}
0 commit comments