rollup-plugin-polyfill-service
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

rollup-plugin-polyfill-service

NPM version MIT licensed

A rollup plugin for analysing your JavaScript file and generating a https://polyfill.io 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://polyfill.io/v3/polyfill.min.js"></script>

When running rollup, rollup-plugin-polyfill-service will analyze the built bundle, generate a https://polyfill.io 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://polyfill.io/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 or RegExp to detect inject location. (default: ${polyfillUrl}[^"' ]*)
  • browserslist: A browserslist query or an object to pass options to browserslist.
  • print: Set to true 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.

Package Sidebar

Install

npm i rollup-plugin-polyfill-service

Weekly Downloads

9

Version

1.0.0

License

MIT

Unpacked Size

19.4 kB

Total Files

13

Last publish

Collaborators

  • mluce