rollup-plugin-polyfill-service
v2.0.0
Published
Rollup plugin that analyse built javascript files and generate a polyfill.io URL based on all features that are being used
Downloads
9
Maintainers
Readme
rollup-plugin-polyfill-service
A rollup plugin for analysing your JavaScript file and generating a https://polyfill.io (new url: https://cdnjs.cloudflare.com/polyfill) URL based on all the features that are being used from within the JavaScript file.
Installation
npm install --save-dev rollup-plugin-polyfill-service
Usage
Configure plugin for rollup:
import polyfill from "rollup-plugin-polyfill-service";
export default {
input: "entry.js",
output: { /* ... */ }
plugins: [
// ...
polyfill({
inject: "index.html"
})
]
}
Add the following line to your index.html
:
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js"></script>
When running rollup, rollup-plugin-polyfill-service
will analyze the built bundle, generate a https://cdnjs.cloudflare.com/polyfill URL based on your needs and inject the URL in your index.html
file.
Configuration
polyfillUrl
: The URL to the polyfill service to generate URL for. (default: https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js)include
: One or more minimatch patterns. (default: *.js)exclude
: One or more minimatch patterns.inject
: One or more path to html files to inject URL in or an object to control injection:target
: One or more path to html files to inject URL in.pattern
: A string orRegExp
to detect inject location. (default:${polyfillUrl}[^"' ]*
)
browserslist
: A browserslist query or an object to pass options to browserslist.query
: A browserslist query....options
: Any browserslist options.
print
: Set totrue
to print the generated URL in the console during build.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Licence
This project is licensed under the MIT License - see the LICENSE file for details.