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

1.3.0 • Public • Published

Rollup-Plugin-Rld

Npm package version Npm package total downloads Npm package license Github tag

A Rollup plugin to reload your webpage when the created bundle is regenerated.

Overview

The Plugin will inject a bootstrapping script into your bundle when Rollup is running watch mode. The script itself will inject a reloading script that listens to a event sent by the created server when Rollup bundles the code.

Requirements

The Plugin was tested with Rollup v3.2.0+, but should run with earlier versions as well. The Plugin requires an LTS Node version (v14.0.0+).

Installing

Using npm or yarn

npm install rollup-plugin-rld -D
#or
yarn add rollup-plugin-rld -D

Usage

If you have not already created a rollup.config.js configuration file, do so like shown below. Include the plugin in the plugins property.

import { rld } from 'rollup-plugin-rld';

export default {
    input: '/src/index.js',
    output: {
        file: '/dist/bundle.js',
        format: 'iife',
    },
    plugins: [
        // The initialization object is optional.
        rld({
            port: 31415,
            host: 'localhost',
            url: 'rld',
        }),
    ],
};

Options

port

Type: number
Default: 31415

The port the plugin will use to listen and dispatch requests on. If your plugin throws an EADDRINUSE error, you can change the property to choose a port not yet used. This can also be useful when you use multiple instances of the plugin.

host

Type: string
Default: localhost

The hostname the server will use to listen to.

url

Type: string
Default: /rld

The url the server will expose. The reload script will use the url to connect to the reload server. The url can be given with or without leading slash.

attributes

Type: Record<string, string>
Default: {}

Attributes is a object that can be used to pass attributes to the created script tag. This can be useful when needing to set attributes like nonce, referrerpolicy or crossorigin.

log

Type: boolean
Default: false

A Boolean flag indicating if a log entry should be created inside the browser when a reload occurs.

Contributing

If you would like to contribute, take a look at the contribution guide.

License

The plugin is licensed under the MIT License.

Package Sidebar

Install

npm i rollup-plugin-rld

Weekly Downloads

3

Version

1.3.0

License

MIT

Unpacked Size

57.4 kB

Total Files

22

Last publish

Collaborators

  • sebastian.dev