@sect/modernizr-loader
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

@sect/modernizr-loader

npm version MIT license

NPM

Get your Modernizr build bundled with webpack.
This Repos forked from peerigon/modernizr-loader.

Features

  • Support webpack 5

Install

$ npm install --save-dev modernizr @sect/modernizr-loader json-loader

Initialization

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

// .modernizrrc
{
  "minify": true,
  "options": [
    "setClasses"
  ],
  "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: [ '@sect/modernizr-loader' ]
      },
      {
        test: /\.modernizrrc(\.json)?$/,
        use: [ '@sect/modernizr-loader', 'json-loader' ]
      }
    ]
  },
  resolve: {
    alias: {
      modernizr$: path.resolve(__dirname, "path/to/.modernizrrc")
    }
  }
}

Usage

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.

Changelog

See CHANGELOG file.

License

See LICENSE file.

Readme

Keywords

Package Sidebar

Install

npm i @sect/modernizr-loader

Weekly Downloads

817

Version

1.0.5

License

MIT

Unpacked Size

33.9 kB

Total Files

6

Last publish

Collaborators

  • sect