• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Modernizr/gulp-modernizr: Gulp wrapper for custom Modernizr builds

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

Modernizr/gulp-modernizr

开源软件地址(OpenSource Url):

https://github.com/Modernizr/gulp-modernizr

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-modernizr

Build Status npm version

A Gulp wrapper for Modernizr.

Note: This plugin uses version 3 of Modernizr. Make sure to check the Github repo for the correct feature names (example: Modernizr.touch was renamed to Modernizr.touchevents).

Usage

First, install gulp-modernizr as a development dependency:

npm install --save-dev gulp-modernizr

Then, add it to your gulpfile.js:

var modernizr = require('gulp-modernizr');

gulp.task('modernizr', function() {
  return gulp.src('./js/*.js')
    .pipe(modernizr())
    .pipe(gulp.dest('build/'))
});

Running the plugin will search for tests in your src files like this one for example:

if (!Modernizr.objectfit) { doSomethingLikeCallAPolyfill(); }

and in this case add the 'objectfit' test to the ouptut file.

API

modernizr(fileName)

fileName

Type: String

You can optionally pass a fileName to name the Modernizr file (defaults to modernizr.js)

gulp.src('./js/*.js')
  .pipe(modernizr('modernizr-custom.js'));

modernizr(/*fileName, */ settings)

settings

Type: Object

You can pass settings as an object. See the customizr repository for valid settings.

gulp.src('./js/*.js')
  .pipe(modernizr({
    'options': ['setClasses'],
    'tests': [
      'webworkers',
      [
        'cssgrid',
        'cssgridlegacy'
      ]
    ],
    excludeTests: ['csstransforms3d']
  })
);

The 'settings' object can also be required from a JSON file:

modernizr-config.json:

{
  'options': ['setClasses'],
  'tests': [
      'webworkers',
      [
          'cssgrid',
          'cssgridlegacy'
      ]
  ],
  excludeTests: ['csstransforms3d']
}

gulpfile.js:

gulp.src('./js/*.js')
 .pipe(modernizr(require('./modernizr-config.json')))

Available Settings

See the customizr repository for valid settings.

settings.crawl

By default, glup-modernizr will not output any Modernizr.js if your gulp.src does not contain any file, regardless of the tests you may have set.

If you only want to output a Modernizr.js file with some tests you set, just pass a fake path to gulp.src:

gulp.src('fake', {allowEmpty: true})
  .pipe(modernizr({
    crawl: false,
    tests: [
      'touchevents',
    ],
  })
)

settings.quiet

Defaults to false, setting it to true suppresses any log output from customizr

settings.uglify

Will never be passed to customizr, see the Gulp guidelines. The option to uglify the build goes against guidelines #1 and #3. Thus, this setting has been removed from this plugin. You may use gulp-uglify to achieve this functionality in Gulp:

gulp.src('./js/*.js')
  .pipe(modernizr())
  .pipe(uglify())
  .pipe(gulp.dest("build/"));

License

Copyright (c) 2022 The Modernizr team Licensed under the MIT license.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
gimm/gulp-live-server: serve your nodejs/static app live发布时间:2022-06-21
下一篇:
Sponsor @m19c on GitHub Sponsors · GitHub发布时间:2022-06-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap