Registry / http-networking / rollup-plugin-serve

rollup-plugin-serve

JSON →
library3.0.0jsnpmunverified

A Rollup plugin to serve bundled files during development with a configurable static server. Current stable version is 3.0.0, released sporadically with updates when needed. Key differentiators: zero-config setup, built-in HTTPS support, history API fallback for SPAs, and multiple content base directories. Compared to alternatives like rollup-plugin-dev, it is lighter and mimics webpack-dev-server options. Supports Rollup v0.60+ for v3, older versions available for earlier Rollup. Ships TypeScript types.

npm install rollup-plugin-serve
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SERV
R
rollup-plugin-serve
http-networkingjavascriptv3.0.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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default
import serve from 'rollup-plugin-serve'
const serve = require('rollup-plugin-serve')
Package is ESM-only; CJS require will fail. TypeScript types are included.
serve
import serve from 'rollup-plugin-serve'
import { serve } from 'rollup-plugin-serve'
The default export is a function; there is no named export 'serve'. The named export scenario is a common mistake.
RollupServeOptions
import type { RollupServeOptions } from 'rollup-plugin-serve'
Type import for TypeScript users, available since version 2.0.0.

Minimal Rollup config using serve plugin to host the dist folder on port 3000 and open the browser.

// rollup.config.js (ESM) import serve from 'rollup-plugin-serve' export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'iife' }, plugins: [ serve({ contentBase: 'dist', port: 3000, open: true, historyApiFallback: true }) ] }
Debug
Known issues
breakingVersion 3.0.0 requires Rollup >= 0.60.0. Older Rollup versions must use rollup-plugin-serve@0.
fix
Upgrade Rollup to >= 0.60.0 or use rollup-plugin-serve@0.
affects: 3.0.0
breakingDefault export changed from named export 'serve' to default export in v1.0.0.
fix
Use `import serve from 'rollup-plugin-serve'` instead of `import { serve } from 'rollup-plugin-serve'`.
affects: >=1.0.0
deprecatedThe option 'openPage' is deprecated in favor of 'open' with a string value.
fix
Use `serve({ open: '/different/page' })` instead of `serve({ open: true, openPage: '/different/page' })`.
affects: >=2.0.0
gotchaMultiple contentBase directories must be provided as an array; passing a string will treat it as a single folder.
fix
Use `contentBase: ['dist', 'static']` for multiple folders.
affects: all
gotchaIf using historyApiFallback as a string, it must start with a slash; otherwise it may be ignored.
fix
Set `historyApiFallback: '/200.html'` (with leading slash).
affects: all
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using CJS require() to import an ESM-only package.
fix
Switch to ESM import syntax or use dynamic import().
TypeError: serve is not a function
Importing the package as named export { serve } instead of default export.
fix
Use `import serve from 'rollup-plugin-serve'`.
Error: contentBase must be a string or array of strings
Passing an invalid type to contentBase option (e.g., number).
fix
Set contentBase to a string like './dist' or an array.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
mimerequiredUsed for MIME type resolution
openeroptionalUsed to open browser on serve start
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
rollup-plugin-serve — npm install rollup-plugin-serve · libregistry