@@ -140,11 +140,12 @@ class Config {
140140 }
141141
142142 get port ( ) {
143- if ( process . env . EASY_ENV_DEV_PORT ) {
144- return process . env . EASY_ENV_DEV_PORT ;
143+ const EASY_ENV_DEV_PORT = `EASY_ENV_DEV_PORT_${ this . pkgInfo . name } ` ;
144+ if ( process . env [ EASY_ENV_DEV_PORT ] ) {
145+ return process . env [ EASY_ENV_DEV_PORT ] ;
145146 }
146- process . env . EASY_ENV_DEV_PORT = tool . getPort ( this . config . port ) ;
147- return process . env . EASY_ENV_DEV_PORT ;
147+ process . env [ EASY_ENV_DEV_PORT ] = tool . getPort ( this . config . port ) ;
148+ return process . env [ EASY_ENV_DEV_PORT ] ;
148149 }
149150
150151 get proxy ( ) {
@@ -211,10 +212,18 @@ class Config {
211212 this . webpackConfig = this . utils . cloneDeep ( require ( './native' ) ) ;
212213 this . loaders = this . utils . cloneDeep ( require ( '../../config/loader' ) ) ;
213214 this . plugins = this . utils . cloneDeep ( require ( '../../config/plugin' ) ) ;
215+
214216 const pkgFile = path . join ( this . baseDir , 'package.json' ) ;
215- const devDependencies = fs . existsSync ( pkgFile ) ? require ( pkgFile ) . devDependencies || { } : { } ;
216- const fullDependencies = require ( '../../package.json' ) . fullDependencies || { } ;
217- this . dependencies = this . utils . getDeps ( devDependencies , fullDependencies ) ;
217+ const defaultPkgInfo = { name : 'webpack-project' , version : '1.0.0' } ;
218+ if ( fs . existsSync ( pkgFile ) ) {
219+ this . pkgInfo = Object . assign ( { } , defaultPkgInfo , require ( pkgFile ) ) ;
220+ const devDependencies = this . pkgInfo . devDependencies || { } ;
221+ const fullDependencies = require ( '../../package.json' ) . fullDependencies || { } ;
222+ this . dependencies = this . utils . getDeps ( devDependencies , fullDependencies ) ;
223+ } else {
224+ this . pkgInfo = defaultPkgInfo ;
225+ this . dependencies = { } ;
226+ }
218227 }
219228
220229 initEnv ( config = { } ) {
0 commit comments