An open API service indexing awesome lists of open source software.

https://github.com/sectsect/modernizr-loader

Get your modernizr build bundled with webpack
https://github.com/sectsect/modernizr-loader

modenizer webpack5

Last synced: about 1 month ago
JSON representation

Get your modernizr build bundled with webpack

Awesome Lists containing this project

README

          

# @sect/modernizr-loader

[![npm version](https://badge.fury.io/js/%40sect%2Fmodernizr-loader.svg)](https://badge.fury.io/js/%40sect%2Fmodernizr-loader) [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)

[![NPM](https://nodei.co/npm/@sect/modernizr-loader.png)](https://nodei.co/npm/@sect/modernizr-loader/)

Get your Modernizr build bundled with webpack.
This Repos forked from [peerigon/modernizr-loader](https://github.com/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

```json
// .modernizrrc
{
"minify": true,
"options": [
"setClasses"
],
"feature-detects": []
}
```

Full list of supported **"options"** and **"feature-detects"** can be found in Modernizr [config-all.json](https://github.com/Modernizr/Modernizr/blob/master/lib/config-all.json).

### Webpack config

[Documentation: Using loaders](https://webpack.js.org/configuration/module/#rule-use)

Put the following code to your webpack config file:

```js
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:

```js
import Modernizr from 'modernizr';

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

See the [Modernizr documentation](https://modernizr.com/docs) for all available options.

## Changelog

See [CHANGELOG](https://github.com/sectsect/modernizr-loader/blob/master/CHANGELOG.md) file.

## License

See [LICENSE](https://github.com/sectsect/modernizr-loader/blob/master/LICENSE) file.