1
1
var path = require ( 'path' ) ;
2
+ var isProduction = require ( './is-production' ) ;
2
3
var configReplace = require ( './broccoli-config-replace' ) ;
3
4
var compileWithTypescript = require ( './broccoli-typescript' ) . default ;
4
5
var SwManifest = require ( './service-worker-manifest' ) . default ;
@@ -66,21 +67,23 @@ Angular2App.prototype.toTree = function () {
66
67
var srcAndTypingsTree = mergeTrees ( [ sourceTree , typingsTree ] ) ;
67
68
var tsTree = new compileWithTypescript ( srcAndTypingsTree , tsconfig ) ;
68
69
70
+ var tsTreeExcludes = [ '*.d.ts' , 'tsconfig.json' ] ;
71
+ var excludeSpecFiles = '**/*.spec.*' ;
72
+
73
+ if ( isProduction ) {
74
+ tsTreeExcludes . push ( excludeSpecFiles ) ;
75
+ }
76
+
69
77
tsTree = new Funnel ( tsTree , {
70
78
srcDir : 'src' ,
71
- exclude : [ '*.d.ts' , 'tsconfig.json' ]
79
+ exclude : tsTreeExcludes
72
80
} ) ;
73
81
74
82
var tsSrcTree = new Funnel ( sourceDir , {
75
83
include : [ '**/*.ts' ] ,
76
84
allowEmpty : true
77
85
} ) ;
78
86
79
- var jsTree = new Funnel ( sourceDir , {
80
- include : [ '**/*.js' ] ,
81
- allowEmpty : true
82
- } ) ;
83
-
84
87
var assetTree = new Funnel ( sourceDir , {
85
88
include : [ '**/*.*' ] ,
86
89
exclude : [ '**/*.ts' , '**/*.js' ] ,
@@ -92,14 +95,13 @@ Angular2App.prototype.toTree = function () {
92
95
destDir : 'vendor'
93
96
} ) ;
94
97
95
- var merged = mergeTrees ( [
96
- assetTree ,
97
- tsSrcTree ,
98
- tsTree ,
99
- jsTree ,
100
- this . index ( ) ,
101
- vendorNpmTree
102
- ] , { overwrite : true } ) ;
98
+ var buildTrees = [ assetTree , tsTree , this . index ( ) , vendorNpmTree ] ;
99
+
100
+ if ( ! isProduction ) {
101
+ buildTrees . push ( tsSrcTree ) ;
102
+ }
103
+
104
+ var merged = mergeTrees ( buildTrees , { overwrite : true } ) ;
103
105
104
106
return mergeTrees ( [ merged , new SwManifest ( [ merged ] ) ] ) ;
105
107
} ;
@@ -198,7 +200,7 @@ Angular2App.prototype.contentFor = function (match, type) {
198
200
Angular2App . prototype . _configReplacePatterns = function ( ) {
199
201
return [ {
200
202
match : / \{ \{ c o n t e n t - f o r [ ' " ] ( .+ ) [ " ' ] \} \} / g,
201
- replacement : this . contentFor . bind ( this )
203
+ replacement : isProduction ? '' : this . contentFor . bind ( this )
202
204
} ] ;
203
205
} ;
204
206
0 commit comments