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 ;
@@ -77,8 +78,8 @@ Angular2App.prototype.toTree = function() {
77
78
allowEmpty : true
78
79
} ) ;
79
80
80
- var jsTree = new Funnel ( sourceDir , {
81
- include : [ '**/* .js' ] ,
81
+ var jsTree = new Funnel ( tsTree , {
82
+ include : [ '**/!(*.spec) .js' ] ,
82
83
allowEmpty : true
83
84
} ) ;
84
85
@@ -93,14 +94,33 @@ Angular2App.prototype.toTree = function() {
93
94
destDir : 'vendor'
94
95
} ) ;
95
96
96
- var merged = mergeTrees ( [
97
+
98
+ var thirdPartyJsTree = new Funnel ( 'node_modules' , {
99
+ include : [ 'ng2*/bundles/*.js' ] ,
100
+ exclude : [ 'ng2*/bundles/*.min.js' , 'ng2*/bundles/*.standalone.js' ] ,
101
+ } ) ;
102
+
103
+ var thirdPartyJs = new Concat ( thirdPartyJsTree , {
104
+ inputFiles : [ '**/*.js' ] ,
105
+ outputFile : '/thirdparty/libs.js' ,
106
+ allowNone : true
107
+ } ) ;
108
+
109
+ var buildTree = [
97
110
assetTree ,
98
- tsSrcTree ,
99
- tsTree ,
100
- jsTree ,
101
111
this . index ( ) ,
102
112
vendorNpmTree ,
103
- ] , { overwrite : true } ) ;
113
+ thirdPartyJs
114
+ ] ;
115
+
116
+ if ( isProduction ) {
117
+ buildTree . push ( jsTree ) ;
118
+ } else {
119
+ buildTree . push ( tsSrcTree ) ;
120
+ buildTree . push ( tsTree ) ;
121
+ }
122
+
123
+ var merged = mergeTrees ( buildTree , { overwrite : true } ) ;
104
124
105
125
return mergeTrees ( [ merged , new SwManifest ( [ merged ] ) ] ) ;
106
126
} ;
@@ -112,10 +132,6 @@ Angular2App.prototype.toTree = function() {
112
132
*/
113
133
Angular2App . prototype . _initProject = function ( ) {
114
134
this . project = Project . closestSync ( process . cwd ( ) ) ;
115
-
116
- /*if (options.configPath) {
117
- this.project.configPath = function() { return options.configPath; };
118
- }*/
119
135
} ;
120
136
121
137
/**
@@ -172,12 +188,6 @@ Angular2App.prototype.initializeAddons = function() {
172
188
Angular2App . prototype . contentFor = function ( match , type ) {
173
189
var content = [ ] ;
174
190
175
- /*switch (type) {
176
- case 'head': this._contentForHead(content, config); break;
177
- case 'config-module': this._contentForConfigModule(content, config); break;
178
- case 'app-boot': this._contentForAppBoot(content, config); break;
179
- }*/
180
-
181
191
content = this . project . addons . reduce ( function ( content , addon ) {
182
192
var addonContent = addon . contentFor ? addon . contentFor ( type ) : null ;
183
193
if ( addonContent ) {
@@ -187,7 +197,6 @@ Angular2App.prototype.contentFor = function(match, type) {
187
197
return content ;
188
198
} , content ) ;
189
199
190
-
191
200
return content . join ( '\n' ) ;
192
201
} ;
193
202
@@ -197,16 +206,12 @@ Angular2App.prototype.contentFor = function(match, type) {
197
206
@return
198
207
*/
199
208
Angular2App . prototype . _configReplacePatterns = function ( ) {
200
- return [ /*{
201
- match: /\{\{EMBER_ENV\}\ }/g,
202
- replacement: calculateEmberENV
203
- }, */ {
209
+ return [
210
+ {
204
211
match : / \{ \{ c o n t e n t - f o r [ ' " ] ( .+ ) [ " ' ] \} \} / g,
205
- replacement : this . contentFor . bind ( this )
206
- } /*, {
207
- match: /\{\{MODULE_PREFIX\}\}/g,
208
- replacement: calculateModulePrefix
209
- }*/ ] ;
212
+ replacement : isProduction ? '' : this . contentFor . bind ( this )
213
+ }
214
+ ] ;
210
215
} ;
211
216
212
217
@@ -228,7 +233,6 @@ Angular2App.prototype.index = function() {
228
233
description : 'Funnel: index.html'
229
234
} ) ;
230
235
231
-
232
236
return configReplace ( index , {
233
237
files : [ htmlName ] ,
234
238
patterns : this . _configReplacePatterns ( )
0 commit comments