Modernizr configuration for val-loader
This configuration is meant to be used in conjunction with val-loader
and will compile
a custom Modernizr build based on a configuration file
that has to be provided.
The setup is based on the official documentation and doesn't include
modernizr
or val-loader
as dependencies, allowing you to use any supported version.
npm install val-loader-modernizr val-loader modernizr --save-dev
Webpack configuration
Add a module rule to the Webpack configuration using val-loader
as the loader with the executableFile
option set to val-loader-modernizr
.
module.exports = {
module: {
rules: [{
test: /\.modernizrrc$/,
use: [{
loader: 'val-loader',
options: {
executableFile: require.resolve('val-loader-modernizr')
}
}]
}]
}
}
Modernizr configuration
Create a Modernizr configuration file and enable the options and feature detects that are needed.
{
"enableClasses": true,
"minify": true,
"feature-detects": [
]
}
Importing
Import the file where needed, the loader will take care of compiling a build and injecting it into the bundle.
import './.modernizrrc';