{"id":22216,"library":"rollup-plugin-serve","title":"rollup-plugin-serve","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/thgh/rollup-plugin-serve","tags":["javascript","rollup","rollup-plugin","serve","dev-server","static","typescript"],"install":[{"cmd":"npm install rollup-plugin-serve","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-serve","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-serve","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for MIME type resolution","package":"mime","optional":false},{"reason":"Used to open browser on serve start","package":"opener","optional":true}],"imports":[{"note":"Package is ESM-only; CJS require will fail. TypeScript types are included.","wrong":"const serve = require('rollup-plugin-serve')","symbol":"default","correct":"import serve from 'rollup-plugin-serve'"},{"note":"The default export is a function; there is no named export 'serve'. The named export scenario is a common mistake.","wrong":"import { serve } from 'rollup-plugin-serve'","symbol":"serve","correct":"import serve from 'rollup-plugin-serve'"},{"note":"Type import for TypeScript users, available since version 2.0.0.","wrong":null,"symbol":"RollupServeOptions","correct":"import type { RollupServeOptions } from 'rollup-plugin-serve'"}],"quickstart":{"code":"// rollup.config.js (ESM)\nimport serve from 'rollup-plugin-serve'\n\nexport default {\n  input: 'src/main.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife'\n  },\n  plugins: [\n    serve({\n      contentBase: 'dist',\n      port: 3000,\n      open: true,\n      historyApiFallback: true\n    })\n  ]\n}","lang":"typescript","description":"Minimal Rollup config using serve plugin to host the dist folder on port 3000 and open the browser."},"warnings":[{"fix":"Upgrade Rollup to >= 0.60.0 or use rollup-plugin-serve@0.","message":"Version 3.0.0 requires Rollup >= 0.60.0. Older Rollup versions must use rollup-plugin-serve@0.","severity":"breaking","affected_versions":"3.0.0"},{"fix":"Use `import serve from 'rollup-plugin-serve'` instead of `import { serve } from 'rollup-plugin-serve'`.","message":"Default export changed from named export 'serve' to default export in v1.0.0.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use `serve({ open: '/different/page' })` instead of `serve({ open: true, openPage: '/different/page' })`.","message":"The option 'openPage' is deprecated in favor of 'open' with a string value.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use `contentBase: ['dist', 'static']` for multiple folders.","message":"Multiple contentBase directories must be provided as an array; passing a string will treat it as a single folder.","severity":"gotcha","affected_versions":"all"},{"fix":"Set `historyApiFallback: '/200.html'` (with leading slash).","message":"If using historyApiFallback as a string, it must start with a slash; otherwise it may be ignored.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Switch to ESM import syntax or use dynamic import().","cause":"Using CJS require() to import an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Use `import serve from 'rollup-plugin-serve'`.","cause":"Importing the package as named export { serve } instead of default export.","error":"TypeError: serve is not a function"},{"fix":"Set contentBase to a string like './dist' or an array.","cause":"Passing an invalid type to contentBase option (e.g., number).","error":"Error: contentBase must be a string or array of strings"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}