Registry / devops / modernizr-webpack-plugin

modernizr-webpack-plugin

JSON →
library1.0.7jsnpmunverified

Generates a custom Modernizr build during webpack compilation with optional html-webpack-plugin integration. Latest version 1.0.7 is stable but no updates since 2017. Key differentiator: automates Modernizr detection feature selection in webpack pipelines, supports [hash] and [chunkhash] in filenames, and can inject script tags into HTML via html-webpack-plugin. Limited to webpack 3 and below; does not support webpack 4 or 5 natively.

npm install modernizr-webpack-plugin
INSTALL
IMPORT
SIG · MODERNIZR-WEBPACK-
M
modernizr-webpack-plugin
devopsjavascriptv1.0.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ModernizrWebpackPlugin
const ModernizrWebpackPlugin = require('modernizr-webpack-plugin');
import ModernizrWebpackPlugin from 'modernizr-webpack-plugin';
Package uses CommonJS and has no default ESM export; named require is correct.
ModernizrWebpackPlugin (with config)
plugins: [new ModernizrWebpackPlugin({ 'feature-detects': ['input'] })]
plugins: [new ModernizrWebpackPlugin({options: { 'feature-detects': ['input'] }})]
Config is passed directly to the constructor, not nested under 'options'.
htmlWebpackPlugin option
new ModernizrWebpackPlugin({ htmlWebpackPlugin: true })
new ModernizrWebpackPlugin({ htmlWebpackPlugin: myHtmlPluginInstance })
Passing the plugin instance directly works but is deprecated in favor of boolean or array.

Shows basic webpack config with Modernizr plugin, feature detection list, and html-webpack-plugin integration.

const ModernizrWebpackPlugin = require('modernizr-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: __dirname + '/dist' }, plugins: [ new HtmlWebpackPlugin(), new ModernizrWebpackPlugin({ 'feature-detects': [ 'input', 'canvas', 'css/resize' ], minify: process.env.NODE_ENV === 'production' ? true : false }) ] };
Debug
Known issues
breakingPlugin incompatible with webpack 4+; may cause build failures or silently produce no output.
fix
Use modernizr-webpack-plugin with webpack 3 or lower, or switch to an alternative like custom-modernizr-webpack-plugin.
affects: >=1.0.0
deprecatedThe htmlWebpackPlugin option accepts instance but that use is deprecated; use boolean or array instead.
fix
Set htmlWebpackPlugin: true or false, or pass an array of instances if needed.
affects: >=1.0.0
gotchaIf filename does not end with .js, the plugin appends it automatically; this may cause unexpected double extensions.
fix
Ensure filename ends with '.js' explicitly to avoid duplication.
affects: >=1.0.0
gotchaminify option defaults based on NODE_ENV=production, which may not be intended in all build scenarios.
fix
Explicitly set minify: true/false in config.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'modernizr-webpack-plugin'
Package not installed or using wrong import syntax in ESM environment.
fix
Run: npm install modernizr-webpack-plugin --save-dev. Use require() instead of import.
TypeError: ModernizrWebpackPlugin is not a constructor
Importing from the package incorrectly (e.g., using default import in ESM).
fix
Use: const ModernizrWebpackPlugin = require('modernizr-webpack-plugin');
Error: html-webpack-plugin not found or not compatible
html-webpack-plugin not installed or incompatible version (requires version 2.x or 3.x).
fix
Install html-webpack-plugin@3.2.0 or use htmlWebpackPlugin: false.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
webpackrequiredRuns as a webpack plugin during compilation
html-webpack-pluginoptionalOptional integration for injecting Modernizr script into HTML
Agent activity
6 hits · last 30 days
node
6
Resources
modernizr-webpack-plugin — npm install modernizr-webpack-plugin · libregistry