https://github.com/sloanelybutsurely/html-webpack-polyfill-io-plugin
https://github.com/sloanelybutsurely/html-webpack-polyfill-io-plugin
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sloanelybutsurely/html-webpack-polyfill-io-plugin
- Owner: sloanelybutsurely
- Created: 2017-10-15T15:10:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-21T13:33:18.000Z (over 2 years ago)
- Last Synced: 2024-11-19T18:41:54.890Z (7 months ago)
- Language: JavaScript
- Size: 66.4 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `HtmlWebpackPolyfillIOPlugin`
[](https://travis-ci.org/zperrault/html-webpack-polyfill-io-plugin)
[](https://github.com/semantic-release/semantic-release)Use the Financial Times' [polyfill.io](https://polyfill.io/v2/docs/) service in your webpack builds with the help of the [`HtmlWebpackPlugin`](https://github.com/jantimon/html-webpack-plugin#html-webpack-plugin).
## Installation
Install the plugin with npm:
```shell
$ npm install --save-dev html-webpack-polyfill-io-plugin
```Install the pluging with yarn:
```shell
yarn add --dev html-webpack-polyfill-io-plugin
```## Usage
Add the plugin to your webpack configuration.
```js
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackPolyfillIOPlugin = require('html-webpack-polyfill-io-plugin')module.exports = {
/* ... */
plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackPolyfillIOPlugin(),
]
}
```## Configuration
The plugin's configuration mirrors that listed at [polyfill.io/v2/docs/api](https://polyfill.io/v2/docs/api) when possible. Documentation here is minimal to avoid duplicating the official documentation.
### (`minify`: `boolean`)
default: `true` when `NODE_ENV === 'production'`, `false` otherwise.
### (`features`: `string|Array`)
Features to include.
May be a string defining a comma separated list of features or an array of features.
### `excludes`
Features to exclude from output.
May be a string defining a comma separated list of features or an array of features.
### (`flags`: `'always'|'gated'`)
default: not set
If set, specifies whether features listed in `features` should be `gated` or `always` included.
### (`callback`: `string`)
A function to be called once the polyfill has been loaded successfully.
Must be a valid javascript identifier.
### (`unknown`: `'ignore'|'polyfill'`)
What to do when the user agent is not recognized.
### (`rum`: `boolean`)
Explicitly enable or diable [real user monitoring](https://en.wikipedia.org/wiki/Real_user_monitoring)
## Example
```js
new HtmlWebpackPolyfillIOPlugin({
minify: true, // Always minify, even in dev
features: [
'Intl',
'Map',
'Set',
'Array.isArray',
'Array.prototype.find',
'Array.prototype.some',
'Object.assign',
'Promise',
], // Features to include
flags: 'always', // Include all specified features regardless of user-agent
unknown: 'polyfill', // Polyfill all listed features if user-agent is unkown
callback: 'polyfillHasLoaded',
rum: true, // Allow real-user monitoring
})
```