All Projects → Modernizr → Gulp Modernizr

Modernizr / Gulp Modernizr

Licence: mit
Gulp wrapper for custom Modernizr builds

Programming Languages

javascript
137047 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Modernizr

Gulp Shell
A handy command line interface for gulp
Stars: ✭ 474 (+327.03%)
Mutual labels:  gulp, gulp-plugin
Gulp Flatten
Gulp plugin: remove or replace relative paths for files
Stars: ✭ 102 (-8.11%)
Mutual labels:  gulp, gulp-plugin
Gulp Pug
Gulp plugin for compiling Pug templates
Stars: ✭ 512 (+361.26%)
Mutual labels:  gulp, gulp-plugin
gulp-yarn
Automatically install node modules using Yarn. 😻
Stars: ✭ 22 (-80.18%)
Mutual labels:  gulp, gulp-plugin
Gulp Json Editor
A gulp plugin to edit JSON objects
Stars: ✭ 55 (-50.45%)
Mutual labels:  gulp, gulp-plugin
gulp-convert-encoding
Plugin for gulp to convert files from one encoding to another.
Stars: ✭ 15 (-86.49%)
Mutual labels:  gulp, gulp-plugin
Gulp Ftp
[DEPRECATED] Upload files to an FTP-server
Stars: ✭ 100 (-9.91%)
Mutual labels:  gulp, gulp-plugin
gulp-tinypng-compress
TinyPNG API wrapper for compressing PNG & JPG images
Stars: ✭ 49 (-55.86%)
Mutual labels:  gulp, gulp-plugin
Gulp Require Tasks
Splits Gulpfile into multiple individual files
Stars: ✭ 51 (-54.05%)
Mutual labels:  gulp, gulp-plugin
Generator Gulp Plugin Boilerplate
Scaffold out a Gulp plugin boilerplate
Stars: ✭ 46 (-58.56%)
Mutual labels:  gulp, gulp-plugin
anyfs
Portable file system for Node
Stars: ✭ 17 (-84.68%)
Mutual labels:  gulp, gulp-plugin
Gulp Plugin Boilerplate
Boilerplate to kickstart creating Gulp plugins
Stars: ✭ 74 (-33.33%)
Mutual labels:  gulp, gulp-plugin
gulp-golang
gulp plugin for golang projects
Stars: ✭ 13 (-88.29%)
Mutual labels:  gulp, gulp-plugin
gulp-markdown-to-json
Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
Stars: ✭ 76 (-31.53%)
Mutual labels:  gulp, gulp-plugin
gulp-iife
A Gulp plugin for wrapping JavaScript code in IIFEs.
Stars: ✭ 39 (-64.86%)
Mutual labels:  gulp, gulp-plugin
Gulp Angular Templatecache
Concatenates and registers AngularJS templates in the $templateCache.
Stars: ✭ 530 (+377.48%)
Mutual labels:  gulp, gulp-plugin
gulp-px2rem
This is a gulp plugin for node-px2rem.
Stars: ✭ 19 (-82.88%)
Mutual labels:  gulp, gulp-plugin
gulp-recess
[DEPRECATED] Lint CSS and LESS with RECESS
Stars: ✭ 42 (-62.16%)
Mutual labels:  gulp, gulp-plugin
Gulp Jsonlint
🔍 jsonlint plugin for Gulp
Stars: ✭ 26 (-76.58%)
Mutual labels:  gulp, gulp-plugin
Gulp Develop Server
Development assistant for node.js server by gulp
Stars: ✭ 72 (-35.14%)
Mutual labels:  gulp, gulp-plugin

gulp-modernizr

npm version Build Status

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) 2020 The Modernizr team Licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected]