@@ -15,6 +15,7 @@ if (!process.env.npm_config_argv) {
15
15
16
16
const escape = arg => `"${ arg } "` ;
17
17
const isTnsCommand = flag => flag . endsWith ( "-app" ) ;
18
+ const isEnvCommand = flag => flag . indexOf ( "env." ) > - 1 ;
18
19
const shouldUglify = ( ) => process . env . npm_config_uglify ;
19
20
const shouldSnapshot = ( platform ) => platform == "android" && require ( "os" ) . type ( ) != "Windows_NT" && process . env . npm_config_snapshot ;
20
21
@@ -34,7 +35,7 @@ function getTnsArgs(args) {
34
35
"--nobundle" ,
35
36
] ;
36
37
37
- return args . filter ( a => ! other . includes ( a ) && ! isTnsCommand ( a ) ) ;
38
+ return args . filter ( a => ! other . includes ( a ) && ! isTnsCommand ( a ) && ! isEnvCommand ( a ) ) ;
38
39
}
39
40
40
41
execute ( options ) ;
@@ -51,7 +52,7 @@ function execute(options) {
51
52
( ) => cleanApp ( platform ) ,
52
53
( ) => cleanSnapshotArtefacts ( ) ,
53
54
( ) => cleanBuildArtifacts ( platform ) ,
54
- ( ) => webpack ( platform ) ,
55
+ ( ) => webpack ( platform , options . env ) ,
55
56
] ;
56
57
}
57
58
@@ -139,7 +140,7 @@ function cleanApp(platform) {
139
140
} ) ;
140
141
}
141
142
142
- function webpack ( platform ) {
143
+ function webpack ( platform , env ) {
143
144
return new Promise ( function ( resolve , reject ) {
144
145
console . log ( `Running webpack for ${ platform } ...` ) ;
145
146
@@ -148,6 +149,7 @@ function webpack(platform) {
148
149
`--config=webpack.config.js` ,
149
150
`--progress` ,
150
151
`--env.${ platform } ` ,
152
+ ...env . map ( item => `--${ item } ` ) ,
151
153
shouldUglify ( ) && `--env.uglify` ,
152
154
shouldSnapshot ( platform ) && `--env.snapshot`
153
155
] ;
@@ -172,11 +174,16 @@ function getOptions(flags) {
172
174
let options = { } ;
173
175
options . platform = getPlatform ( flags ) ;
174
176
options . command = getCommand ( flags ) ;
177
+ options . env = getEnv ( flags ) ;
175
178
options . bundle = ! flags . includes ( "nobundle" ) ;
176
179
177
180
return options ;
178
181
}
179
182
183
+ function getEnv ( flags ) {
184
+ return flags . filter ( item => isEnvCommand ( item ) ) ;
185
+ }
186
+
180
187
function getPlatform ( flags ) {
181
188
if ( flags . includes ( "android" ) && flags . includes ( "ios" ) ) {
182
189
throwError ( { message : "You cannot use both --android and --ios flags!" } ) ;
0 commit comments