Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
gulp-modernizr
Advanced tools
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
).
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.
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'));
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')))
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/"));
Copyright (c) 2024 The Modernizr team Licensed under the MIT license.
FAQs
Gulp wrapper for custom Modernizr builds
We found that gulp-modernizr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.