A Rollup plugin to reload your webpage when the created bundle is regenerated.
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.
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+).
Using npm or yarn
npm install rollup-plugin-rld -D
#or
yarn add rollup-plugin-rld -D
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',
}),
],
};
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.
Type: string
Default: localhost
The hostname the server will use to listen to.
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.
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
.
Type: boolean
Default: false
A Boolean flag indicating if a log entry should be created inside the browser when a reload occurs.
If you would like to contribute, take a look at the contribution guide.
The plugin is licensed under the MIT License.