@@ -181,13 +181,20 @@ gulp.task('build', ['build-themes', 'build-scss', 'build-js']);
181
181
182
182
183
183
gulp . task ( 'build-all-modules' , function ( ) {
184
- var addedCore = false ;
185
184
return gulp . src ( [ 'src/components/*' , 'src/core/' , ] )
186
185
. pipe ( through2 . obj ( function ( folder , enc , next ) {
187
186
var moduleId = folder . path . indexOf ( 'components' ) > - 1 ?
188
187
'material.components.' + path . basename ( folder . path ) :
189
188
'material.' + path . basename ( folder . path ) ;
190
- buildModule ( moduleId ) . on ( 'end' , function ( ) {
189
+
190
+ var stream ;
191
+ if ( IS_RELEASE_BUILD ) {
192
+ stream = mergeStream ( buildModule ( moduleId , true ) , buildModule ( moduleId , false ) ) ;
193
+ } else {
194
+ stream = buildModule ( moduleId , false ) ;
195
+ }
196
+
197
+ stream . on ( 'end' , function ( ) {
191
198
next ( ) ;
192
199
} ) ;
193
200
} ) ) ;
@@ -292,16 +299,25 @@ gulp.task('build-js-release', function() {
292
299
* @return {function(): Stream }
293
300
*/
294
301
function minifyJs ( fileName ) {
295
- // Return a function instead of the stream itself in order to work with
296
- // lazypipe.
297
- return closureCompiler ( {
298
- compilerPath : 'bower_components/closure-compiler/lib/vendor/compiler.jar' ,
299
- fileName : fileName ,
300
- compilerFlags : {
301
- language_in : 'ECMASCRIPT5' ,
302
- warning_level : 'QUIET'
303
- }
304
- } ) ;
302
+ // Figure out filename if not provided
303
+ if ( ! fileName ) {
304
+ return through2 . obj ( function ( file , enc , next ) {
305
+ closure ( path . basename ( file . path ) ) . on ( 'data' , this . push . bind ( this ) ) ;
306
+ next ( ) ;
307
+ } ) ;
308
+ } else {
309
+ return closure ( fileName ) ;
310
+ }
311
+ function closure ( fileName ) {
312
+ return closureCompiler ( {
313
+ compilerPath : 'bower_components/closure-compiler/lib/vendor/compiler.jar' ,
314
+ fileName : fileName ,
315
+ compilerFlags : {
316
+ language_in : 'ECMASCRIPT5' ,
317
+ warning_level : 'QUIET'
318
+ }
319
+ } ) ;
320
+ }
305
321
}
306
322
307
323
@@ -353,37 +369,33 @@ function buildTheme(theme) {
353
369
354
370
355
371
gulp . task ( 'build-module' , [ 'build-demo' ] , function ( ) {
356
- return buildModule ( readModuleArg ( ) ) ;
372
+ return buildModule ( readModuleArg ( ) , IS_RELEASE_BUILD ) ;
357
373
} ) ;
358
374
359
- function buildModule ( module ) {
375
+ function buildModule ( module , isRelease ) {
360
376
var name = module . split ( '.' ) . pop ( ) ;
361
- gutil . log ( 'Building module' , module , '...' ) ;
377
+ gutil . log ( 'Building module' , module , isRelease && 'minified' || '' , '...' ) ;
362
378
return utils . filesForModule ( module )
363
379
. pipe ( filterNonCodeFiles ( ) )
364
380
. pipe ( gulpif ( '*.scss' , buildModuleStyles ( name ) ) )
365
381
. pipe ( gulpif ( '*.js' , buildModuleJs ( name ) ) )
366
382
. pipe ( BUILD_MODE . transform ( ) )
367
383
. pipe ( insert . prepend ( config . banner ) )
368
- . pipe ( gulp . dest ( BUILD_MODE . outputDir + name ) )
369
- . pipe ( gulpif ( IS_RELEASE_BUILD , lazypipe ( )
370
- . pipe ( gulpif , BUILD_MODE . useBower , lazypipe ( )
371
- . pipe ( gulpif , / .c s s $ / , minifyCss ( ) , through2 . obj ( function ( file , enc , next ) {
372
- var name = path . basename ( file . path ) ;
373
- minifyJs ( name ) . on ( 'data' , this . push . bind ( this ) ) ;
374
- next ( ) ;
375
- } ) )
376
- . pipe ( rename , function ( path ) {
377
- path . extname = path . extname
378
- . replace ( / .j s $ / , '.min.js' )
379
- . replace ( / .c s s $ / , '.min.css' ) ;
380
- } )
381
- . pipe ( utils . buildModuleBower , name , VERSION )
382
- ( )
383
- )
384
+ . pipe ( gulpif ( isRelease && BUILD_MODE . useBower , buildMin ( ) ) )
385
+ . pipe ( gulp . dest ( BUILD_MODE . outputDir + name ) ) ;
386
+
387
+ function buildMin ( ) {
388
+ return lazypipe ( )
389
+ . pipe ( gulpif , / .c s s $ / , minifyCss ( ) , minifyJs ( ) )
390
+ . pipe ( rename , function ( path ) {
391
+ path . extname = path . extname
392
+ . replace ( / .j s $ / , '.min.js' )
393
+ . replace ( / .c s s $ / , '.min.css' ) ;
394
+ } )
395
+ . pipe ( utils . buildModuleBower , name , VERSION )
384
396
. pipe ( gulp . dest , BUILD_MODE . outputDir + name )
385
- ( )
386
- ) ) ;
397
+ ( ) ;
398
+ }
387
399
}
388
400
389
401
@@ -393,7 +405,7 @@ gulp.task('build-demo', function() {
393
405
var demoIndexTemplate = fs . readFileSync (
394
406
__dirname + '/docs/demos/demo-index.template.html' , 'utf8'
395
407
) . toString ( ) ;
396
-
408
+
397
409
gutil . log ( 'Building demos for' , mod , '...' ) ;
398
410
return utils . readModuleDemos ( mod , function ( ) {
399
411
return lazypipe ( )
0 commit comments