You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

webpack-modernizr-loader

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-modernizr-loader

Get your modernizr build bundled with webpack, use modernizr with webpack easily

1.0.2
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

webpack-modernizr-loader

NPM version Travis Build Status dependencies Status devDependencies Status

Get your modernizr build bundled with webpack.

Installation

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

Initialization

You have to create a .modernizrrc (or .modernizrrc.js) configuration file and put your modernizr stuff in it. Like so:

// .modernizrrc or .modernizrrc.json
{
    "options": [
        "setClasses"
    ],
    "feature-detects": [
        "test/css/flexbox",
        "test/es6/promises",
        "test/serviceworker"
    ]
}

Or

'use strict';

module.exports = {
    "options": [
        "setClasses"
    ],
    "feature-detects": [
        "test/css/flexbox",
        "test/es6/promises",
        "test/serviceworker"
    ]
};

Full list of supported "options" and their "description" can be found in modernizr.

Webpack config

Documentation: Using loaders

Put the following code to your webpack config file:

module.exports = {
  module: {
    loaders: [
      {
        loader: "modernizr",
        test: /\.modernizrrc$/, // or "/\.modernizrrc\.json$/", or "/\.modernizrrc\.js$/"
      }
    ]
  },
  resolve: {
    alias: {
      modernizr$: path.resolve(__dirname, "path/to/.modernizr") // or "path/to/.modernizr.json", or "path/to/.modernizr.js"
    }
  }
}

Alternative configurations supported dynamic configuration:

module.exports = {
  module: {
    loaders: [
      {
       loader: `modernizr?config=${encodeURI(JSON.stringify(modernizrConfig))}`,
       test: /modernizr$/
      }
    ]
  },
  resolve: {
    alias: {
      modernizr$: path.resolve(__dirname, "path/to/empty-file") // You can add comment "Please do not delete this file" in this file
    }
  }
}

Note: webpack normalize query to loader.

Using config through query string is have large priority than through resolve.alias.

Usage

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

import 'modernizr';

You can used bundle plugin for async loading:

import modernizrLoader from 'bundle?lazy!modernizr';

modernizrLoader(() => {});
  • Modernizr - API for this module

Contribution

Feel free to push your code if you agree with publishing under the MIT license.

Changelog

License

Keywords

modernizr

FAQs

Package last updated on 31 Jan 2017

Did you know?

Socket

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.

Install

Related posts