@@ -15,16 +15,16 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
15
15
private $projectData : IProjectData ,
16
16
) { super ( ) ; }
17
17
18
- public async compileWithWatch ( platformData : IPlatformData , projectData : IProjectData , config : IWebpackCompilerConfig ) : Promise < any > {
18
+ public async compileWithWatch ( platformData : IPlatformData , projectData : IProjectData , prepareData : IPrepareData ) : Promise < any > {
19
19
return new Promise ( async ( resolve , reject ) => {
20
20
if ( this . webpackProcesses [ platformData . platformNameLowerCase ] ) {
21
21
resolve ( ) ;
22
22
return ;
23
23
}
24
24
25
25
let isFirstWebpackWatchCompilation = true ;
26
- config . watch = true ;
27
- const childProcess = await this . startWebpackProcess ( platformData , projectData , config ) ;
26
+ prepareData . watch = true ;
27
+ const childProcess = await this . startWebpackProcess ( platformData , projectData , prepareData ) ;
28
28
29
29
childProcess . on ( "message" , ( message : any ) => {
30
30
if ( message === "Webpack compilation complete." ) {
@@ -69,14 +69,14 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
69
69
} ) ;
70
70
}
71
71
72
- public async compileWithoutWatch ( platformData : IPlatformData , projectData : IProjectData , config : IWebpackCompilerConfig ) : Promise < void > {
72
+ public async compileWithoutWatch ( platformData : IPlatformData , projectData : IProjectData , prepareData : IPrepareData ) : Promise < void > {
73
73
return new Promise ( async ( resolve , reject ) => {
74
74
if ( this . webpackProcesses [ platformData . platformNameLowerCase ] ) {
75
75
resolve ( ) ;
76
76
return ;
77
77
}
78
78
79
- const childProcess = await this . startWebpackProcess ( platformData , projectData , config ) ;
79
+ const childProcess = await this . startWebpackProcess ( platformData , projectData , prepareData ) ;
80
80
childProcess . on ( "close" , ( arg : any ) => {
81
81
const exitCode = typeof arg === "number" ? arg : arg && arg . code ;
82
82
if ( exitCode === 0 ) {
@@ -100,8 +100,8 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
100
100
101
101
@performanceLog ( )
102
102
@hook ( 'prepareJSApp' )
103
- private async startWebpackProcess ( platformData : IPlatformData , projectData : IProjectData , config : IWebpackCompilerConfig ) : Promise < child_process . ChildProcess > {
104
- const envData = this . buildEnvData ( platformData . platformNameLowerCase , config . env ) ;
103
+ private async startWebpackProcess ( platformData : IPlatformData , projectData : IProjectData , prepareData : IPrepareData ) : Promise < child_process . ChildProcess > {
104
+ const envData = this . buildEnvData ( platformData . platformNameLowerCase , prepareData ) ;
105
105
const envParams = this . buildEnvCommandLineParams ( envData , platformData ) ;
106
106
107
107
const args = [
@@ -111,19 +111,20 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
111
111
...envParams
112
112
] ;
113
113
114
- if ( config . watch ) {
114
+ if ( prepareData . watch ) {
115
115
args . push ( "--watch" ) ;
116
116
}
117
117
118
- const stdio = config . watch ? [ "inherit" , "inherit" , "inherit" , "ipc" ] : "inherit" ;
118
+ const stdio = prepareData . watch ? [ "inherit" , "inherit" , "inherit" , "ipc" ] : "inherit" ;
119
119
const childProcess = this . $childProcess . spawn ( "node" , args , { cwd : projectData . projectDir , stdio } ) ;
120
120
121
121
this . webpackProcesses [ platformData . platformNameLowerCase ] = childProcess ;
122
122
123
123
return childProcess ;
124
124
}
125
125
126
- private buildEnvData ( platform : string , env : any ) {
126
+ private buildEnvData ( platform : string , prepareData : IPrepareData ) {
127
+ const { env } = prepareData ;
127
128
const envData = Object . assign ( { } ,
128
129
env ,
129
130
{ [ platform . toLowerCase ( ) ] : true }
@@ -137,6 +138,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
137
138
) ;
138
139
139
140
envData . verbose = this . $logger . isVerbose ( ) ;
141
+ envData . production = prepareData . release ;
140
142
141
143
return envData ;
142
144
}
0 commit comments