@applaud/webpack-modernizr-loader

1.0.1 • Public • Published

@applaud/webpack-modernizr-loader

NPM version Travis Build Status dependencies Status devDependencies Status Greenkeeper badge

Get your modernizr build bundled with webpack.

Installation

$ npm install @applaud/webpack-modernizr-loader --save-dev

Usage

Documentation: Using loaders

There are three use case.

  1. Using loader options.
import modernizr from 'modernizr'; // or `const modernizr = require('modernizr');`

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        loader: 'webpack-modernizr-loader',
        options: {
          // Full list of supported options can be found in [config-all.json](https://github.com/Modernizr/Modernizr/blob/master/lib/config-all.json).
          options: [
            "setClasses"
          ],
          "feature-detects": [
            "test/css/flexbox",
            "test/es6/promises",
            "test/serviceworker"
          ]
        },
        test: /empty-alias-file\.js$/
      }
    ]
  },
  resolve: {
    alias: {
      // You can add comment "Please do not delete this file" in this file
      modernizr$: path.resolve(__dirname, "/path/to/empty-alias-file.js")
    }
  }
}
  1. Using config file through alias (supported JavaScript and JSON syntax).
import modernizr from 'modernizr'; // or `const modernizr = require('modernizr');`

.modernizrrc.js

"use strict";

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

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        loader: "webpack-modernizr-loader",
        test: /\.modernizrrc\.js$/
      }
    ]
  },
  resolve: {
    alias: {
      modernizr$: path.resolve(__dirname, "/path/to/.modernizrrc.js")
    }
  }
}
  1. Using config (supported JavaScript and JSON syntax) file directly (see below example how it is use).
import modernizr from './.modernizrrc.js';

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        loader: "webpack-modernizr-loader",
        test: /\.modernizrrc\.js$/
      }
    ]
  }
}

Related

Contribution

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

Changelog

License

Package Sidebar

Install

npm i @applaud/webpack-modernizr-loader

Weekly Downloads

21

Version

1.0.1

License

MIT

Unpacked Size

9.52 kB

Total Files

5

Last publish

Collaborators

  • mahesh_reddy