javascriptgruntjsmodernizrgetusermedia

Custom grunt-modernizr with non-core detects


Since the day I discovered yeoman, I use it for all my front-end projects.

It includes grunt-modernizr that - at least I think - download the library and compiles it on the fly when I call the build task

grunt build

But I have a small problem : by defaults, it does not include the "non-core detects" that we can see online here : modernizr custom builder

Here is my grunt-modernizr task config (part of the Gruntfile.js file) :

modernizr: {
    devFile: '<%= yeoman.app %>/components/modernizr/modernizr.js',
    outputFile: '<%= yeoman.dist %>/components/modernizr/modernizr.js',
    extra: {
        'shiv' : true,
        'printshiv' : false,
        'load' : true,
        'mq' : false,
        'cssclasses' : true
    },
    extensibility: {
        'addtest': true,
        'prefixed': false,
        'teststyles': false,
        'testprops': false,
        'testallprops': false,
        'hasevents': false,
        'prefixes': false,
        'domprefixes': false
    },
    files: [
        '<%= yeoman.dist %>/scripts/{,*/}*.js',
        '<%= yeoman.dist %>/styles/{,*/}*.css',
        '!<%= yeoman.dist %>/scripts/vendor/*'
    ],
    uglify: true
}

In fact I would like to use Modernizr.getusermedia, but as a non-core feature, it is not defined... Because the grunt-modernizr config does not seem to allow the non-core detects inclusion.

Any idea about this point?

EDIT: the modernizr task does not work anymore ; even when I remove the "extra" and "extensibility" properties...

Running "modernizr" task

Enabled Extras
>> shiv
>> load
>> cssclasses

Looking for Modernizr references

in dist/styles/main.min.css
>> svg
>> input

Downloading source files
cache modernizr-latest.js
cache modernizr.load.1.5.4.js

>> Generating a custom Modernizr build
Fatal error: Invalid regular expression: /TEST__flexbox']=function(){return testPropsAll('flexWrap');};tests['flexboxlegacy__/: Unterminated character class

Solution

  • You can, check out stu cox's answer here

    essentially,

    either use the matchCommunityTests config flag to let grunt-modernizr find references to non-core tests in your code, or name them explicitly in your tests config