Get your modernizr build bundled with webpack, use modernizr with webpack easily
npm install webpack-modernizr-loader



Get your modernizr build bundled with webpack.
``shell`
$ npm install webpack-modernizr-loader --save-dev
There are three use case.
1. Using loader options.
`javascript`
const modernizr = require("modernizr");
webpack.config.js
`javascriptJSON
module.exports = {
module: {
rules:
{
loader: "webpack-modernizr-loader",
options: {
// Full list of supported options can be found in [config-all.json.
options: ["setClasses"],
"feature-detects": [
"test/css/flexbox",
"test/es6/promises",
"test/serviceworker"
]
// Uncomment this when you use format for configuration`
// type: 'javascript/auto'
},
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")
}
}
};
2. Using config file through alias (supported JavaScript and JSON syntax).
`javascript`
const modernizr = require("modernizr");
.modernizrrc.js
`javascript`
module.exports = {
options: ["setClasses"],
"feature-detects": [
"test/css/flexbox",
"test/es6/promises",
"test/serviceworker"
]
};
webpack.config.js
`javascriptJSON
module.exports = {
module: {
rules: [
{
loader: "webpack-modernizr-loader",
test: /\.modernizrrc\.js$/
// Uncomment this when you use format for configuration`
// type: 'javascript/auto'
}
]
},
resolve: {
alias: {
modernizr$: path.resolve(__dirname, "/path/to/.modernizrrc.js")
}
}
};
3. Using config (supported JavaScript and JSON syntax) file directly (see below example how it is use).
`javascript`
const modernizr = require("modernizr");
webpack.config.js
`javascriptJSON
module.exports = {
module: {
rules: [
{
loader: "webpack-modernizr-loader",
test: /\.modernizrrc\.js$/
// Uncomment this when you use format for configuration``
// type: 'javascript/auto'
}
]
}
};
- Modernizr - API for this module
Feel free to push your code if you agree with publishing under the MIT license.