1
1
var path = require ( 'path' ) ;
2
2
var Concat = require ( 'broccoli-concat' ) ;
3
+ var isProduction = require ( './is-production' ) ;
3
4
var configReplace = require ( './broccoli-config-replace' ) ;
4
5
var compileWithTypescript = require ( './broccoli-typescript' ) . default ;
5
6
var SwManifest = require ( './service-worker-manifest' ) . default ;
@@ -41,8 +42,6 @@ Angular2App.prototype.toTree = function() {
41
42
'angular2/bundles/upgrade.dev.js'
42
43
] ;
43
44
44
-
45
-
46
45
if ( this . options && this . options . vendorNpmFiles ) {
47
46
vendorNpmFiles = vendorNpmFiles . concat ( this . options . vendorNpmFiles ) ;
48
47
}
@@ -79,8 +78,8 @@ Angular2App.prototype.toTree = function() {
79
78
allowEmpty : true
80
79
} ) ;
81
80
82
- var jsTree = new Funnel ( sourceDir , {
83
- include : [ '**/* .js' ] ,
81
+ var jsTree = new Funnel ( tsTree , {
82
+ include : [ '**/!(*.spec) .js' ] ,
84
83
allowEmpty : true
85
84
} ) ;
86
85
@@ -106,15 +105,21 @@ Angular2App.prototype.toTree = function() {
106
105
allowNone : true
107
106
} ) ;
108
107
109
- var merged = mergeTrees ( [
108
+ var buildTree = [
110
109
assetTree ,
111
- tsSrcTree ,
112
- tsTree ,
113
- jsTree ,
114
110
this . index ( ) ,
115
111
vendorNpmTree ,
116
112
thirdPartyJs
117
- ] , { overwrite : true } ) ;
113
+ ] ;
114
+
115
+ if ( isProduction ) {
116
+ buildTree . push ( jsTree ) ;
117
+ } else {
118
+ buildTree . push ( tsSrcTree ) ;
119
+ buildTree . push ( tsTree ) ;
120
+ }
121
+
122
+ var merged = mergeTrees ( buildTree , { overwrite : true } ) ;
118
123
119
124
return mergeTrees ( [ merged , new SwManifest ( merged ) ] ) ;
120
125
} ;
@@ -126,10 +131,6 @@ Angular2App.prototype.toTree = function() {
126
131
*/
127
132
Angular2App . prototype . _initProject = function ( ) {
128
133
this . project = Project . closestSync ( process . cwd ( ) ) ;
129
-
130
- /*if (options.configPath) {
131
- this.project.configPath = function() { return options.configPath; };
132
- }*/
133
134
} ;
134
135
135
136
/**
@@ -186,12 +187,6 @@ Angular2App.prototype.initializeAddons = function() {
186
187
Angular2App . prototype . contentFor = function ( match , type ) {
187
188
var content = [ ] ;
188
189
189
- /*switch (type) {
190
- case 'head': this._contentForHead(content, config); break;
191
- case 'config-module': this._contentForConfigModule(content, config); break;
192
- case 'app-boot': this._contentForAppBoot(content, config); break;
193
- }*/
194
-
195
190
content = this . project . addons . reduce ( function ( content , addon ) {
196
191
var addonContent = addon . contentFor ? addon . contentFor ( type ) : null ;
197
192
if ( addonContent ) {
@@ -201,7 +196,6 @@ Angular2App.prototype.contentFor = function(match, type) {
201
196
return content ;
202
197
} , content ) ;
203
198
204
-
205
199
return content . join ( '\n' ) ;
206
200
} ;
207
201
@@ -211,16 +205,12 @@ Angular2App.prototype.contentFor = function(match, type) {
211
205
@return
212
206
*/
213
207
Angular2App . prototype . _configReplacePatterns = function ( ) {
214
- return [ /*{
215
- match: /\{\{EMBER_ENV\}\ }/g,
216
- replacement: calculateEmberENV
217
- }, */ {
208
+ return [
209
+ {
218
210
match : / \{ \{ c o n t e n t - f o r [ ' " ] ( .+ ) [ " ' ] \} \} / g,
219
- replacement : this . contentFor . bind ( this )
220
- } /*, {
221
- match: /\{\{MODULE_PREFIX\}\}/g,
222
- replacement: calculateModulePrefix
223
- }*/ ] ;
211
+ replacement : isProduction ? '' : this . contentFor . bind ( this )
212
+ }
213
+ ] ;
224
214
} ;
225
215
226
216
@@ -242,7 +232,6 @@ Angular2App.prototype.index = function() {
242
232
description : 'Funnel: index.html'
243
233
} ) ;
244
234
245
-
246
235
return configReplace ( index , {
247
236
files : [ htmlName ] ,
248
237
patterns : this . _configReplacePatterns ( )
0 commit comments