Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: node_js
node_js:
- "6"
- "5.11"
deploy:
provider: npm
email: ohwubang@gmail.com
api_key:
secure: D+66esLlGtDv3AYF2tGsbKu+7DYxS2RTSd1qvDruPpaq093LlFYK3OaiY1BonAJgJypApFfBAje15RUJpWuMJc0Lx9bPrL4I1YmZ1ar11xzpq8xwHpZctlvfZcRnB3N4MhF2wNiKifgSvF6pfMYcjRVHxxBHxGBUSyfQBTz5sJH+z5j3XVeyP1/ycpTu7resp0ijHC8hN0JdGsY6ky3VbDES3wiYHztFkgLcWrVtha8khv91aZGT+JztWpXIeF/3j382YMMCERMKO5ogtDhonM/gPYoS1MIFzE7KPGTFuP3CX6oVbe4GyxdIzXCBCiTqYac8JAceBenYt1MhjIMzr+PrF+I7z8hfzdWiBXkQyaZDJncPO39fhczUBFJdHSXBHFXzTvK1U0G+piD3rPZf1sYdLQ2FQiih6gte7mBZpMY7jSR4elS/Ld+Hr2ZodFR3vVxMm4+/tslSSknndHyWftq/jGJyLjwgxS9t0SJVENQlCVHRihAyaOAr3m0SHh6vRW+VjBV0ebeOLN5q7LtA0ET26+iOY4EbsLBXv5KxSXoFv15v3OVtBfh7rV2UfMxnYigob4Tq8FIzMjmn1y6a63qU8aCMZaWCO2rEQNQzdNPumMXe5drfczAFX6/k/xZFeJkiZVPiYPsDf4w+M56bfj/+nMwb18Gb0UiGa/oDKI0=
on:
tags: true
repo: bangwu/webpack-polyfills-plugin
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
[![npm version](https://badge.fury.io/js/webpack-polyfills-plugin.svg)](https://badge.fury.io/js/webpack-polyfills-plugin)
[![npm version](https://badge.fury.io/js/polyfills-webpack-plugin.svg)](https://badge.fury.io/js/polyfills-webpack-plugin)

# webpack-polyfills-plugin
# polyfills-webpack-plugin

Adds polyfills from [polyfill-service](https://github.com/Financial-Times/polyfill-service) to bundle file. Without magic.


Now the **maintained** plugin, forked from https://github.com/beda-software/webpack-polyfills-plugin/ and ownership transferred.

## Usage:

* Fist Parameter is which you want to Polyfills
* Second Parameter is provide for customer config which file you do not want to Poly, If you not provide this parameter, All files will execute Poly. This must be a Regular Expression

```javascript
var PolyfillsPlugin = require('webpack-polyfills-plugin');
var PolyfillsPlugin = require('polyfills-webpack-plugin');

module.exports = {

Expand All @@ -18,9 +22,8 @@ module.exports = {
plugins: [
new PolyfillsPlugin([
'Array/prototype/find',
'fetch',
'Object/assign'
])
'fetch'
], /\.(css|scss)$/)
]
}
```
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
var ConcatSource = require("webpack-core/lib/ConcatSource");
var fs = require("fs");

function PolyfillsPlugin(polyfills) {
function PolyfillsPlugin(polyfills, exclude) {
this.polyfills = polyfills || [];
this.exclude = exclude;
}

module.exports = PolyfillsPlugin;

PolyfillsPlugin.prototype.apply = function(compiler) {

var filesContent = "";
var that = this;

this.polyfills.forEach(function(polyfill) {
var filePath = require.resolve("./polyfills/" + polyfill + "/polyfill");
Expand All @@ -28,7 +30,9 @@ PolyfillsPlugin.prototype.apply = function(compiler) {
}

chunk.files.forEach(function(file, i) {
if(that.exclude == undefined || !file.match(that.exclude)){
compilation.assets[file] = new ConcatSource("/* Polyfills */\n", filesContent, compilation.assets[file]);
}
});
});
callback();
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{

"name": "webpack-polyfills-plugin",
"version": "0.2.0",
"description": "Adds polyfills to bundle file, without magic.",
Expand All @@ -8,6 +9,7 @@
},
"repository": {
"type": "git",

"url": "https://github.com/oayres/webpack-polyfills-plugin"
},
"keywords": [
Expand Down