Get your modernizr build bundled with webpack
Switch branches/tags
Nothing to show
Clone or download
samtsai and flootr Add extra details about `json-loader` and rules (#37)
* Add extra details about `json-loader` and rules

* Upgrade to webpack2 and update tests/docs

Update tests rule set up to more closely match webpack2 docs
Update link to webpack2 documentation

Upgrade ava and fix path to test fixtures

Fix package lock
Latest commit bb337ac Jun 10, 2017

modernizr-loader for webpack

Build Status devDependency Status peerDependency Status


$ npm install --save-dev modernizr modernizr-loader json-loader


You have to create a .modernizrrc configuration file and put your modernizr stuff in it. Like so

// .modernizrrc
  "minify": true,
  "options": [
  "feature-detects": []

Full list of supported "options" and "feature-detects" can be found in Modernizr config-all.json.

Webpack config

Documentation: Using loaders

Put the following code to your webpack config file:

const path = require('path');

module.exports = {
  module: {
    rules: [
        test: /\.modernizrrc.js$/,
        use: [ 'modernizr-loader' ]
        test: /\.modernizrrc(\.json)?$/,
        use: [ 'modernizr-loader', 'json-loader' ]
  resolve: {
    alias: {
      modernizr$: path.resolve(__dirname, "path/to/.modernizrrc")


Now you are able to import your custom Modernizr build as a module throughout your application like so:

import Modernizr from 'modernizr';

if (!Modernizr.promises) {
    // ...

See the Modernizr documentation for all available options.


Don't hesitate to create a pull request. Every contribution is appreciated.