modernizr-loader for webpack
Installation
$ npm install --save-dev modernizr-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
Put the following code to your webpack config file:
module.exports = {
module: {
loaders: [
{
test: /\.modernizrrc$/,
loader: "modernizr"
}
]
},
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.
Contribution
Don't hesitate to create a pull request. Every contribution is appreciated.