File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,9 +9,8 @@ process.on('message', m => {
99 const baseDir = m . baseDir ;
1010 const target = m . target ;
1111 const webpackConfig = utils . getWebpackConfig ( config , { baseDir, target } ) ;
12- const EASY_ENV_DEV_PORT = process . env . EASY_ENV_DEV_PORT ;
13- const webPort = Number ( EASY_ENV_DEV_PORT || m . port ) ;
14- const nodePort = Number ( EASY_ENV_DEV_PORT || m . port ) + 1 ;
12+ const webPort = utils . getPort ( m . port ) ;
13+ const nodePort = webPort + 1 ;
1514 const port = target === 'web' ? webPort : nodePort ;
1615 const webpackTool = new WebpackTool ( { port } ) ;
1716 compiler = webpackTool . createWebpackCompiler ( webpackConfig , ( ) => {
Original file line number Diff line number Diff line change @@ -3,6 +3,15 @@ const path = require('path');
33const fs = require ( 'fs' ) ;
44const IMG_REGEX = / \. ( p n g | j p e ? g | g i f | s v g ) ( \? .* ) ? $ / ;
55const PKG_PREFIX = '@easy-team' ;
6+
7+ exports . getPkgInfo = baseDir => {
8+ const pkgFile = path . join ( baseDir || process . cwd ( ) , 'package.json' ) ;
9+ if ( fs . existsSync ( pkgFile ) ) {
10+ return require ( pkgFile ) ;
11+ }
12+ return { } ;
13+ } ;
14+
615exports . readWebpackMemoryFile = ( compiler , filePath ) => {
716 const compilerList = Array . isArray ( compiler ) ? compiler : [ compiler ] ;
817 for ( let i = 0 ; i < compilerList . length ; i ++ ) {
@@ -131,6 +140,10 @@ exports.normalizeProxyUrlFile = (app, url) => {
131140 return path . join ( app . baseDir , url ) ;
132141} ;
133142
143+ // fix child process running mutil count
134144exports . getPort = port => {
135- return Number ( process . env . EASY_ENV_DEV_PORT || port ) ;
136- } ;
145+ const pkgInfo = exports . getPkgInfo ( ) ;
146+ const name = pkgInfo . name || 'webpack-project' ;
147+ const EASY_ENV_DEV_PORT = `EASY_ENV_DEV_PORT_${ name } ` ;
148+ return Number ( process . env [ EASY_ENV_DEV_PORT ] || port ) ;
149+ } ;
You can’t perform that action at this time.
0 commit comments