PolyfillServicePlugin
This is a webpack plugin that detects required polyfills using autopolyfiller and loads them from Polyfill service.
Installation
npm install polyfill-service-webpack
and then add the PolyfillServicePlugin
to the webpack config:
var PolyfillServicePlugin = ;var webpackConfig = plugins: minify: true callback: "onPolyfillsLoaded" defaultFeatures: "Object.assing": "always" flags: libVersion: ">0.0.0" unknown: "polyfill" ;
After that, you can invoke the special function __load_polyfills__
from your JS:
// request the polyfillsvar polyfillsLoaded = ; ;
Options
minify
- type:
boolean
. - default:
false
.
Whether to minify the result. If false, debugging information will be inserted.
callback
- type:
string
. - default:
onPolyfillsLoaded
.
What name to use for the global callback triggered when the polyfills have loaded.
defaultFeatures
- type:
object
. - default:
{}
.
A map of features to include regardless of whether they're detected. The keys are the feature names and the values are arrays of flags to apply. See the docs for further information about the flags.
flags
- type:
array
. - default:
[]
.
A list of flags to apply to every feature.
libVersion
- type:
string
. - default: empty.
Version of the polyfill collection to use. Accepts any valid semver expression. If not specified, the latest version of the library is used.
unknown
- type:
string
- default: empty
What to do when the user agent is not recognized. See the docs.