@@ -94,12 +94,12 @@ class Angular2App {
9494 this . initializeAddons ( ) ;
9595 this . project . addons = this . project . addons . filter ( function ( addon ) {
9696 addon . app = this ;
97-
97+
9898 if ( ! addon . isEnabled || addon . isEnabled ( ) ) {
9999 if ( addon . included ) {
100100 addon . included ( this ) ;
101101 }
102-
102+
103103 return addon ;
104104 }
105105 } , this ) ;
@@ -139,7 +139,7 @@ class Angular2App {
139139 */
140140 _contentFor ( match , type ) {
141141 var content = [ ] ;
142-
142+
143143 /*switch (type) {
144144 case 'head': this._contentForHead(content, config); break;
145145 case 'config-module': this._contentForConfigModule(content, config); break;
@@ -151,14 +151,14 @@ class Angular2App {
151151 if ( addonContent ) {
152152 return content . concat ( addonContent ) ;
153153 }
154-
154+
155155 return content ;
156156 } , content ) ;
157-
158-
157+
158+
159159 return content . join ( '\n' ) ;
160160 }
161-
161+
162162 /**
163163 * @private
164164 * @method _getReplacePatterns
@@ -183,19 +183,19 @@ class Angular2App {
183183 var files = [
184184 'index.html'
185185 ] ;
186-
186+
187187 var index = new Funnel ( this . _sourceDir , {
188188 files : files ,
189189 description : 'Funnel: index.html'
190190 } ) ;
191-
192-
191+
192+
193193 return configReplace ( index , {
194194 files : [ htmlName ] ,
195195 patterns : this . _getReplacePatterns ( )
196196 } ) ;
197197 }
198-
198+
199199 /**
200200 * Returns the source root dir tree.
201201 *
@@ -223,7 +223,7 @@ class Angular2App {
223223 destDir : 'typings'
224224 } ) ;
225225 }
226-
226+
227227 /**
228228 * Returns the TS tree.
229229 *
@@ -234,6 +234,7 @@ class Angular2App {
234234 _getTsTree ( ) {
235235 var typingsTree = this . _getTypingsTree ( ) ;
236236 var sourceTree = this . _getSourceTree ( ) ;
237+ var configTree = this . _getConfigTree ( ) ;
237238
238239 var tsConfigPath = path . join ( this . _sourceDir , 'tsconfig.json' ) ;
239240 var tsconfig = JSON . parse ( fs . readFileSync ( tsConfigPath , 'utf-8' ) ) ;
@@ -264,23 +265,23 @@ class Angular2App {
264265 // Because the tsconfig does not include the source directory, add this as the first path
265266 // element.
266267 tsconfig . files = tsconfig . files . map ( name => path . join ( this . _sourceDir , name ) ) ;
267-
268- var srcAndTypingsTree = mergeTrees ( [ sourceTree , typingsTree ] ) ;
269- var tsTree = new compileWithTypescript ( srcAndTypingsTree , tsconfig ) ;
270-
268+
269+ var mergedTree = mergeTrees ( [ sourceTree , typingsTree , configTree ] , { overwrite : true } ) ;
270+ var tsTree = new compileWithTypescript ( mergedTree , tsconfig ) ;
271+
271272 var tsTreeExcludes = [ '*.d.ts' , 'tsconfig.json' ] ;
272273 var excludeSpecFiles = '**/*.spec.*' ;
273-
274+
274275 if ( isProduction ) {
275276 tsTreeExcludes . push ( excludeSpecFiles ) ;
276277 tsTree = uglify ( tsTree ) ;
277278 }
278-
279+
279280 tsTree = new Funnel ( tsTree , {
280281 srcDir : this . _sourceDir ,
281282 exclude : tsTreeExcludes
282283 } ) ;
283-
284+
284285 return tsTree ;
285286 }
286287
@@ -305,19 +306,19 @@ class Angular2App {
305306 'angular2/bundles/router.dev.js' ,
306307 'angular2/bundles/upgrade.dev.js'
307308 ] ;
308-
309+
309310 if ( this . _options . vendorNpmFiles ) {
310311 vendorNpmFiles = vendorNpmFiles . concat ( this . _options . vendorNpmFiles ) ;
311312 }
312-
313+
313314 var vendorNpmTree = new Funnel ( 'node_modules' , {
314315 include : vendorNpmFiles ,
315316 destDir : 'vendor'
316317 } ) ;
317-
318+
318319 return vendorNpmTree ;
319320 }
320-
321+
321322 /**
322323 * Returns the `assets` tree.
323324 *
@@ -353,6 +354,23 @@ class Angular2App {
353354 allowEmpty : true
354355 } ) ;
355356 }
357+
358+ /**
359+ * Returns the config files tree.
360+ *
361+ * @private
362+ * @method _getConfigTree
363+ * @return {Tree } The config files tree.
364+ */
365+ _getConfigTree ( ) {
366+ var envConfigFile = isProduction ? 'environment.prod.ts' : 'environment.dev.ts' ;
367+ // console.log(envConfigFile);
368+ return new Funnel ( 'config' , {
369+ include : [ envConfigFile ] ,
370+ destDir : 'src/client/app' ,
371+ getDestinationPath : ( ) => 'environment.ts'
372+ } ) ;
373+ }
356374}
357375
358376module . exports = Angular2App ;
0 commit comments