https://github.com/peerigon/modernizr-loader
Get your modernizr build bundled with webpack
https://github.com/peerigon/modernizr-loader
modernizr modernizr-loader webpack
Last synced: 5 months ago
JSON representation
Get your modernizr build bundled with webpack
- Host: GitHub
- URL: https://github.com/peerigon/modernizr-loader
- Owner: peerigon
- License: mit
- Created: 2015-11-17T10:50:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-08T18:57:31.000Z (over 8 years ago)
- Last Synced: 2025-09-27T11:31:51.914Z (9 months ago)
- Topics: modernizr, modernizr-loader, webpack
- Language: JavaScript
- Size: 57.6 KB
- Stars: 163
- Watchers: 13
- Forks: 19
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# modernizr-loader for webpack
[](https://travis-ci.org/peerigon/modernizr-loader) [](https://david-dm.org/peerigon/modernizr-loader#info=devDependencies) [](https://david-dm.org/peerigon/modernizr-loader#info=peerDependencies)
## Installation
```
$ npm install --save-dev modernizr modernizr-loader json-loader
```
## Initialization
You have to create a `.modernizrrc` configuration file and put your modernizr stuff in it. Like so
```javascript
// .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:
```javascript
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")
}
}
}
```
### Usage
Now you are able to import your custom Modernizr build as a module throughout your application like so:
```javscript
import Modernizr from 'modernizr';
if (!Modernizr.promises) {
// ...
}
```
See the [Modernizr documentation](https://modernizr.com/docs) for all available options.
## Contribution
Don't hesitate to create a pull request. Every contribution is appreciated.
## Sponsors
[
](https://peerigon.com)