![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
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({
excludeTests: ['csstransforms3d']
}));
The 'settings' object can also be required from a JSON file:
modernizr-config.json:
{
'options': ['setClasses'],
'tests': ['webworkers']
}
gulpfile.js:
gulp.src('./js/*.js')
.pipe(modernizr(require('./modernizr-config.json')))
settings.crawl
Currently not passed on to customizr, see issue #36
settings.uglify
Per 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) 2018 Veeck Licensed under the MIT license.
FAQs
Gulp wrapper for custom Modernizr builds
The npm package gulp-modernizr receives a total of 2,499 weekly downloads. As such, gulp-modernizr popularity was classified as popular.
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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.