A webpack loader that enables importing custom Modernizr builds as modules. Version 1.0.1 requires modernizr ^3.1.0 as a peer dependency. Maintained by peerigon. Unlike manual builds, this integrates seamlessly with webpack's module system, allowing feature detection to be bundled conditionally. The loader reads a .modernizrrc (JSON or JS) configuration file. Breaking change in 1.0.0: Modernizr is no longer attached to window; must import as a module. Supports webpack 1 and 2, but webpack 1 requires json-loader for JSON configs.
npm install modernizr-loaderVerified import paths — ran on the pinned version, not inferred.
Shows setup of .modernizrrc config, webpack loader rules for JS and JSON configs, alias, and usage in app.
Change from using window.Modernizr to import Modernizr from 'modernizr'.
Add 'modernizr!json' loader chain for .modernizrrc(.json)? files, or switch to JS config with .modernizrrc.js.
Refer to Modernizr's config-all.json for supported options and feature-detects.
Use 'modernizr$' in alias key.
Add resolve.alias.modernizr$ pointing to your .modernizrrc file.
Add loader rules for .modernizrrc(.js)? and .modernizrrc(.json)? as shown in quickstart.
Run npm install --save-dev modernizr
Rename to .modernizrrc.js and use loader: 'modernizr' (no json). Or for JSON, keep .modernizrrc.json and use 'modernizr!json' loader.