Using gulp-modernizr how do I specify feature opti

2019-05-23 00:53发布

问题:

My custom Moderniser build includes the following options which I am trying to inject into the gulp-modernizr tool as follows:

gulp.task('modernizr', function() {
  allUISrcPlusSassSrc
    .pipe(modernizr({
      options: [
        'backdropfilter',
        'backgroundsize',
        'bgpositionxy',
        'bgrepeatspace_bgrepeatround',
        'bgsizecover',
        'borderradius',
        'cssanimations',
        'cssfilters',
        'csspointerevents',
        'csspseudoanimations',
        'csspseudotransitions',
        'cssremunit',
        'csstransforms',
        'csstransitions',
        'customevent',
        'devicemotion_deviceorientation',
        'eventlistener',
        'flexbox',
        'fontface',
        'json',
        'nthchild',
        'opacity',
        'overflowscrolling',
        'rgba',
        'svg',
        'svgasimg',
        'svgfilters',
        'touchevents',
        'xhrresponsetypejson',
        'domprefixes',
        'setclasses',
        'shiv'
      ]
    }))
    .pipe(gulp.dest("./output/js/vendor/"))
});

But running this leads to Building your customized Modernizr{ [Error: Error: ENOENT: no such file or directory, open '/Users/davesag/src/test-project/node_modules/modernizr/lib/../src/backgroundsize.js'

Looking in ./node_modules/modernizr/src I can't see any files that match these options. Am I just misunderstanding something? These feature names came straight from my custom-built modernizr file as downloaded previously from the moderniser website includes the following options which I am trying to inject into the gulp-modernizr.

Leaving out the options it builds okay but without the options I'm not getting any feature-classes injected into the HTML element of my page. The supposed auto-detect stuff does not seem to be working.

I checked the Customizr page as per the docs and it seems what I am doing is right. But clearly that's not the case.

How should I be doing this?

回答1:

options refers to the options that are on the left hand side of the Modernizr builder page. These are typically APIs and convenience functions like Modernizr.mq, Modernizr.atRule, etc.

You want to use the tests option



回答2:

@Patrick "it doesn't by default. you need to add options: ["setclasses"]"

Actually it's options: ["setClasses"]