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