自从我发现 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
最佳答案
本质上,
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/