javascript – 自定义grunt-modernizr与非核心检测

前端之家收集整理的这篇文章主要介绍了javascript – 自定义grunt-modernizr与非核心检测前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
从我发现 @L_403_0@的那一天起,我就将它用于我的所有前端项目.

包括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配置似乎不允许非核心检测到包含.
关于这一点的任何想法?

编辑:现代化任务不再起作用;即使我删除了“额外”和“可扩展性”属性……

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

原文链接:https://www.f2er.com/js/157666.html

猜你在找的JavaScript相关文章