Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

xuqingkuang/webpack-polyfill-service-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stories in Ready

npm version Dependency Status

webpack-polyfill-service-plugin

Adds polyfills via polyfill-service to bundle file.

Usage:

  • uaString: String, optional. The user agent to evaluate for polyfills that should be included conditionally (advise against as this plugin is for building a bundle that is browser agnostic)

  • unknown: String, optional. What to do when the user agent is not recognised. Set to polyfill to return polyfills for all qualifying features, ignore to return nothing. Defaults to polyfill.

  • minify: Boolean, optional. Whether to minify the bundle

  • features: Object, optional. An object with the features that are to be considered for polyfill inclusion. If not supplied, no features will be considered and the output will be blank. To load the default feature set, set features to {default:{}}. Each feature must be an entry in the features object with the key corresponding to the name of the feature and the value an object with the following properties:

    • flags: Array, optional. Array of flags to apply to this feature (see below)
  • Flags that may be applied to polyfills are:

    • gated: Wrap this polyfill in a feature-detect, to avoid overwriting the native implementation
    • always: Include this polyfill regardless of the user-agent
var PolyfillsPlugin = require('webpack-polyfill-service-plugin');

module.exports = {

	 // ...

	plugins: [
		new PolyfillsPlugin({
			minify: false,
			features: {
				'Array.prototype.forEach': {flags: ['always', 'gated']},
				'Array.prototype.includes': {flags: ['always', 'gated']},
				'Object.assign': {flags: ['always', 'gated']},
				'Promise': {flags: ['always', 'gated']},
				'String.prototype.includes': {flags: ['always', 'gated']}
			}
		}),
	]
}

About

webpack-polyfill-service-plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%