diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5f1b710 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 2453532..a7f08e6 100644 --- a/README.md +++ b/README.md @@ -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 = { @@ -18,9 +22,8 @@ module.exports = { plugins: [ new PolyfillsPlugin([ 'Array/prototype/find', - 'fetch', - 'Object/assign' - ]) + 'fetch' + ], /\.(css|scss)$/) ] } ``` diff --git a/index.js b/index.js index 6c9c77d..01c14f0 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,9 @@ 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; @@ -10,6 +11,7 @@ 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"); @@ -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(); diff --git a/package.json b/package.json index fc1630b..cdafef8 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "name": "webpack-polyfills-plugin", "version": "0.2.0", "description": "Adds polyfills to bundle file, without magic.", @@ -8,6 +9,7 @@ }, "repository": { "type": "git", + "url": "https://github.com/oayres/webpack-polyfills-plugin" }, "keywords": [