rollup-plugin-live-server

raw JSON →
2.0.0 verified Mon Apr 27 auth: no javascript maintenance

A Rollup plugin that wraps live-server to provide a webpack-dev-server-like experience with live reload. Current stable version is 2.0.0. Release cadence is low (last release 2019). Key differentiator: leverages live-server's mature feature set (HTTPS, mounting, open browser, etc.) without reinventing the wheel. Unlike rollup-plugin-serve, it provides live reload via WebSocket injection into HTML files. Suitable for development builds but not actively maintained.

error Error: Cannot find module 'live-server'
cause live-server is not installed as a peer dependency.
fix
Run: npm install --save-dev live-server
error TypeError: plugins[i].name is not a function
cause Using default import instead of named import.
fix
Use: import { liveServer } from 'rollup-plugin-live-server';
error Error: [object Object] is not a valid option for mount
cause The mount option is provided as an object instead of an array of arrays.
fix
Change mount to an array of tuples: mount: [['/from', '/to']]
error Error: Port 8001 is already in use
cause Another process is using the specified port.
fix
Change the port option or kill the other process.
gotcha Plugin options are passed directly to live-server; consult live-server docs for all options.
fix Refer to https://www.npmjs.com/package/live-server for full option list.
deprecated Package last updated in 2019 with no recent maintenance; may not work with Rollup v3+.
fix Consider alternatives like rollup-plugin-serve or @web/dev-server.
gotcha The plugin requires live-server to be installed as a peer dependency. Ensure it's in your package.json.
fix Run npm install --save-dev live-server.
gotcha The 'mount' option expects an array of arrays, not an object. Incorrect format will cause errors.
fix Use mount: [['/from', '/to']] format.
gotcha The 'file' option must be a relative path from root, not absolute.
fix Ensure file is relative, e.g., 'index.html' instead of '/absolute/path/index.html'.
npm install rollup-plugin-live-server
yarn add rollup-plugin-live-server
pnpm add rollup-plugin-live-server

Shows how to configure and use the plugin in a Rollup config, including common options like port, root, and file.

// rollup.config.js
import { liveServer } from 'rollup-plugin-live-server';

export default {
  input: 'src/index.js',
  plugins: [
    liveServer({
      port: 8001,
      host: '0.0.0.0',
      root: 'public',
      file: 'index.html',
      open: false,
      wait: 500,
    }),
  ],
  output: {
    dir: 'dist',
    format: 'es',
  },
};