55
66module . exports = function ( gulp , $ , options ) {
77
8+ var defaultConfig = require ( '../gulp-config/modernizr.conf.json' ) ;
9+
810 var distConfig = {
911
1012 cache : true ,
@@ -14,23 +16,7 @@ module.exports = function (gulp, $, options) {
1416 dest : options . paths . tmp + '/assets/vendors/modernizr/modernizr.js' ,
1517
1618 // Based on default settings on http://modernizr.com/download/
17- options : [
18- 'setClasses' ,
19- 'addTest' ,
20- 'html5printshiv' ,
21- 'testProp' ,
22- 'fnBind' ,
23- 'atRule' ,
24- 'domPrefixes' ,
25- 'hasEvent' ,
26- 'html5shiv' ,
27- 'mq' ,
28- 'prefixed' ,
29- 'prefixes' ,
30- 'prefixedCSS' ,
31- 'testAllProps' ,
32- 'testStyles'
33- ] ,
19+ options : defaultConfig . options ,
3420
3521 // By default, source is uglified before saving
3622 uglify : true ,
@@ -67,7 +53,7 @@ module.exports = function (gulp, $, options) {
6753 } ;
6854
6955
70- gulp . task ( 'modernizr' , function ( done ) {
56+ gulp . task ( 'modernizr' , [ 'modernizr:html5shiv' ] , function ( done ) {
7157 var fs = require ( 'fs' ) ,
7258 filePath = options . assetsPath ( 'dist.vendors' , '/modernizr' ) ,
7359 fullConfig ,
@@ -77,7 +63,25 @@ module.exports = function (gulp, $, options) {
7763
7864 if ( options . production ) {
7965 modernizr = require ( 'customizr' ) ;
80- modernizr ( distConfig , function ( ) {
66+ modernizr ( distConfig , function ( obj ) {
67+ var tests = obj . options [ 'feature-detects' ] ,
68+ logStr = 'The production build includes the following tests: ' ,
69+ colors = $ . util . colors ;
70+ if ( tests . length > 0 ) {
71+
72+
73+ logStr += colors . bold ( tests . map ( function ( test ) {
74+ return test . replace ( 'test/' , '' ) ;
75+ } ) . join ( ', ' ) ) ;
76+
77+ $ . util . log ( logStr ) ;
78+
79+ $ . util . log (
80+ 'For optimal performances you might add a `defer` attribute to the script tag. ' +
81+ 'Refer to https://github.com/Modernizr/Modernizr/issues/878#issuecomment-41448059 for guidelines'
82+ ) ;
83+ }
84+
8185 done ( ) ;
8286 } ) ;
8387 } else {
@@ -93,6 +97,15 @@ module.exports = function (gulp, $, options) {
9397
9498 } ) ;
9599
100+ gulp . task ( 'modernizr:html5shiv' , function ( ) {
101+
102+ var path = require ( 'path' ) ,
103+ html5shivPath = path . join ( path . dirname ( require . resolve ( 'html5shiv' ) ) , '*.min.js' ) ;
104+
105+ return gulp . src ( [ html5shivPath ] )
106+ . pipe ( gulp . dest ( options . assetsPath ( 'dist.vendors' , 'html5shiv/dist' ) ) ) ;
107+ } ) ;
108+
96109} ;
97110
98111
0 commit comments