Registry / web-framework / rollup-plugin-server

rollup-plugin-server

JSON →
library0.7.0jsnpmunverified

rollup-plugin-server is a Rollup plugin that provides a basic development server for serving bundled applications. It simplifies the development workflow by allowing developers to serve static files from specified content base directories, enabling quick testing of Rollup output in a browser. The plugin supports features like history API fallback, custom host and port configuration, and optional HTTPS serving using user-provided SSL certificates. The current stable version is 0.7.0, with no recent updates, suggesting a maintenance-mode project rather than active feature development. Its primary differentiation lies in its direct integration into the Rollup configuration for a lightweight, build-time server.

npm install rollup-plugin-server
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SERV
R
rollup-plugin-server
web-frameworkjavascriptv0.7.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

server
import server from 'rollup-plugin-server'
const server = require('rollup-plugin-server')
The plugin is primarily consumed in ESM `rollup.config.js` files. While CommonJS `require` might work in some older Node environments, `import` is the idiomatic way for Rollup configurations.
server
server({ open: true, contentBase: 'dist' })
server({ contentBase: ['dist'], open: 'true' })
The plugin's default export is a function that takes either a string for `contentBase` or an options object. Boolean options like `open` should be actual booleans, not strings.
ssl_key
import fs from 'fs'; /* ... */ ssl_key: fs.readFileSync('server.key')
ssl_key: 'server.key'
For HTTPS, `ssl_key` and `ssl_cert` expect buffer content read from files (e.g., using Node's `fs.readFileSync`), not just file paths. The `fs` module is a Node.js built-in.

This quickstart demonstrates configuring `rollup-plugin-server` to serve a basic Rollup bundle from a 'dist' directory, automatically opening the browser to `http://localhost:10001`.

import server from 'rollup-plugin-server'; import path from 'path'; import fs from 'fs'; // Create a dummy entry file for Rollup to process const entryFilePath = path.resolve(__dirname, 'entry.js'); fs.writeFileSync(entryFilePath, 'console.log("Hello from Rollup bundle!");'); // Create a dummy dist directory and an index.html const distDirPath = path.resolve(__dirname, 'dist'); if (!fs.existsSync(distDirPath)) { fs.mkdirSync(distDirPath); } const indexHtmlPath = path.join(distDirPath, 'index.html'); fs.writeFileSync(indexHtmlPath, '<!DOCTYPE html>\n<html><head><title>Rollup App</title></head><body><div id="app"></div><script src="bundle.js"></script></body></html>'); export default { input: entryFilePath, output: { file: path.join(distDirPath, 'bundle.js'), format: 'esm' }, plugins: [ server({ open: true, // Automatically open the browser verbose: true, // Show server address in console contentBase: distDirPath, // Serve files from the 'dist' directory host: 'localhost', port: 10001, historyApiFallback: true // Serve index.html for 404s }) ] };
Debug
Known issues
gotchaThe plugin is currently at version 0.7.0 and has not seen updates for several years. While functional, it might not be actively maintained, and future Rollup versions could introduce incompatibilities.
fix
Thoroughly test with your specific Rollup version and project setup. Consider forking or using a more actively maintained alternative if issues arise with newer Rollup versions.
affects: <1.0
gotchaWhen using `ssl: true`, the `ssl_key` and `ssl_cert` options require the actual certificate and key content (e.g., read using `fs.readFileSync`), not just their file paths. Improperly formatted or invalid certificate data will cause the HTTPS server to fail.
fix
Ensure `ssl_key` and `ssl_cert` are correctly populated with the buffer contents of valid SSL/TLS certificates and private keys. Example: `ssl_key: fs.readFileSync('server.key')`.
affects: >=0.1.0
gotchaIf the specified `port` (default 10001) is already in use by another process, the server will fail to start without a clear message in some environments. This can lead to silent failures or errors related to address binding.
fix
Choose a different `port` number if you encounter issues starting the server, or ensure no other applications are using the default port. On Linux/macOS, `lsof -i :<port>` can identify processes using a port.
affects: >=0.1.0
deprecatedThe README and examples show `entry` and `dest` options in the Rollup config. These options are deprecated in modern Rollup versions (>=1.0) in favor of `input` and `output.file` or `output.dir`.
fix
Update your Rollup configuration to use `input` for the entry point and `output.file` (for single bundles) or `output.dir` (for code splitting) for the output destination, as shown in the quickstart example.
affects: >=0.1.0
Errors
Common errors & fixes
Error: listen EADDRINUSE: address already in use :::10001
The configured server port (e.g., 10001) is already being used by another application or a previous instance of your development server.
fix
Change the `port` option in your `server()` plugin configuration to an unused port number (e.g., 10002) or terminate the process currently occupying the port.
ENOENT: no such file or directory, open 'path/to/server.key'
The `ssl_key` or `ssl_cert` option in your server configuration points to a file that does not exist at the specified path.
fix
Verify that the paths provided to `fs.readFileSync()` for `ssl_key` and `ssl_cert` are correct and that the files exist relative to where your Rollup configuration is run.
RollupError: Could not resolve entry.js
Rollup cannot find the entry file specified in your `input` (or deprecated `entry`) configuration. This is often a pathing issue or the file doesn't exist.
fix
Ensure the `input` path in your Rollup configuration correctly points to an existing JavaScript entry file. Use `path.resolve(__dirname, 'your-entry.js')` for robustness.
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies
rolluprequiredThis is a plugin for Rollup and requires Rollup to be installed as a peer dependency.
Agent activity
8 hits · last 30 days
node
8
Resources
rollup-plugin-server — npm install rollup-plugin-server · libregistry