# modernizr-webpack-plugin

> Creates a custom Modernizr build during webpack compile. Integrates with html-webpack-plugin.

Latest version **1.0.7** (published 2018-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install modernizr-webpack-plugin
pnpm add modernizr-webpack-plugin
yarn add modernizr-webpack-plugin
bun add modernizr-webpack-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-03-16 |
| First published | 2015-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Alessandro Palombaro |
| Maintainers | alexpalombaro |
| Keywords | webpack, plugin, modernizr, html-webpack-plugin |

## Links

- npm: https://www.npmjs.com/package/modernizr-webpack-plugin
- Repository: https://github.com/alexpalombaro/modernizr-webpack-plugin
- Homepage: https://github.com/alexpalombaro/modernizr-webpack-plugin#readme
- Issues: https://github.com/alexpalombaro/modernizr-webpack-plugin/issues
- npm.io page: https://npm.io/package/modernizr-webpack-plugin

## Dependencies (5)

- [modernizr](https://npm.io/package/modernizr.md) ^3.5.0
- [uglify-js](https://npm.io/package/uglify-js.md) ^2.4.24
- [webpack-core](https://npm.io/package/webpack-core.md) ^0.6.7
- [object-assign](https://npm.io/package/object-assign.md) ^4.0.1
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^1.6.2

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2018-03-16
- 1.0.6 — 2017-06-01
- 1.0.5 — 2015-11-24
- 1.0.4 — 2015-11-17
- 1.0.3 — 2015-10-22
- 1.0.2 — 2015-10-22
- 1.0.1 — 2015-10-20
- 1.0.0 — 2015-10-19
- 1.0.0-beta.7 — 2015-10-15
- 1.0.0-beta.6 — 2015-10-15
- 1.0.0-beta.5 — 2015-10-14
- 1.0.0-beta.3 — 2015-10-14
- 1.0.0-beta.2 — 2015-10-14
- 1.0.0-beta.1 — 2015-10-13
- 1.0.0-beta — 2015-10-13
- … 4 more at https://npm.io/package/modernizr-webpack-plugin/versions

## README

# modernizr-webpack-plugin

Generate a custom modernizr build during webpack compile.
Includes support to integrate with [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin)

[![npm version](https://badge.fury.io/js/modernizr-webpack-plugin.svg)](https://badge.fury.io/js/modernizr-webpack-plugin)
[![Build Status](https://travis-ci.org/alexpalombaro/modernizr-webpack-plugin.svg?branch=master)](https://travis-ci.org/alexpalombaro/modernizr-webpack-plugin)

## Install

```sh
$ npm install modernizr-webpack-plugin
```

## Usage

Add the modernizr-webpack-plugin to your list of plugins in the webpack config

```javascript
// webpack.config.js
var ModernizrWebpackPlugin = require('modernizr-webpack-plugin');

module.exports = {
  entry: 'app.js',
  output: {
    filename: 'app-bundle.js'
  },
  plugins: [
    new ModernizrWebpackPlugin()
  ]
}
```

## Config

ModernizrWebpackPlugin supports all the options available to [Modernizr](https://github.com/Modernizr/Modernizr/blob/master/lib/config-all.json).

```javascript
// webpack.config.js
...
var config = {
  'feature-detects': [
    'input',
    'canvas',
    'css/resize'
  ]
}

module.exports = {
  ...
  plugins: [
    // Output modernizr-bundle.js with 'input',  
    // 'canvas' and 'css/resize' feature detects
    new ModernizrWebpackPlugin(config)
  ]
}
```

Additional options available via following config properties.

### filename
Type: string

Optional custom output filename. Support included for `[hash]` and `[chunkhash]` in output name.
Defaults to `modernizr-bundle.js`.
*Note:* Will append `.js` extension if missing.

```javascript
var config = {
  filename: 'my-bundle-name[chunkhash].js',
}
```

### minify
Type: boolean | object

Option to minify Modernizr bundle. Accepts `true`, `false` or `object`.
For details of available minify options when using `object` please refer to [uglify-js](https://www.npmjs.com/package/uglify-js)
Defaults to `true` if NODE_ENV is `production` otherwise `false`.

```javascript
var config = {
  minify: {
    output: {
      comments: true,
      beautify: true
    }
  }
}
```

## htmlWebpackPlugin
Type: boolean | object | array

Option to include support for [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin).
Defaults to `true`.

```javascript
// define variable if specifying instance to inject into
var plugin = new HtmlWebpackPlugin();
webpackConfig = {...
   plugins: [
     plugin,  
     new ModernizrWebpackPlugin({
       // auto search through all webpack plugins for compatible
       // html-webpack-plugins and inject into all
       htmlWebpackPlugin: true
       // OR disable any html-webpack-plugin injection
       htmlWebpackPlugin: false
       // OR inject into the instance specified
       htmlWebpackPlugin: plugin
       // OR inject into each of the instances specified
       htmlWebpackPlugin: [plugin]
     })
   ]
}

```

## noChunk
Type: boolean

Option to simplify [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin) template reference
Defaults to `false`.

```javascript
var htmlWebpackPluginConfig = {
  template:'template.html'
}
var modernizrPluginConfig = {
  filename: 'mybundle',
  noChunk: true
}
```

_template.html_
```html
<!-- example of template without noChunk-->
<script src="<%= htmlWebpackPlugin.files.chunks['mybundle'].entry %>"></script>

<!-- example of template WITH noChunk-->
<script src="<%= htmlWebpackPlugin.files.mybundle %>"></script>

```

---
_Source: https://npm.io/package/modernizr-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
