javascript - 具有非核心检测的自定义 grunt-modernizr

标签 javascript gruntjs modernizr getusermedia

自从我发现 yeoman 的那天起,我将它用于我所有的前端项目。

它包括 grunt-modernizr - 至少我认为 - 下载库并在我调用构建任务时即时编译它

grunt build

但我有一个小问题:默认情况下,它不包括我们可以在这里在线看到的“非核心检测”:modernizr custom builder

这是我的 grunt-modernizr 任务配置(Gruntfile.js 文件的一部分):

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
}

其实我很想用Modernizr.getusermedia,但是作为一个非核心特性,没有定义... 因为 grunt-modernizr 配置似乎不允许包含非核心检测。

关于这一点有什么想法吗?

编辑:modernizr 任务不再有效;即使我删除了“额外”和“可扩展性”属性......

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

最佳答案

可以,查看stu cox的回答here

本质上,

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

关于javascript - 具有非核心检测的自定义 grunt-modernizr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20688399/

相关文章:

javascript onclick 撇号引号问题

javascript - 在loop rivets js中设置其他属性

node.js - 将 grunt 添加到 dev-dependency 时无法解析 json

node.js - grunt windows 7路径问题

jquery - 如何创建固定的垂直导航?

javascript - Vue 中的 Spotify 验证 : getting URL params

javascript - Reset() 函数不起作用,为什么?

gruntjs - 如何卸载npm包?

在对象文字中设置变量时,Javascript 速记三元运算符不起作用

带有过渡和弹出窗口的 CSS3 导航