{"id":16199,"library":"rollup-plugin-server","title":"Rollup Development Server Plugin","description":"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.","status":"maintenance","version":"0.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/fkei/rollup-plugin-server","tags":["javascript","rollup","rollup-plugin","serve","server","dev-server","static"],"install":[{"cmd":"npm install rollup-plugin-server","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a plugin for Rollup and requires Rollup to be installed as a peer dependency.","package":"rollup","optional":false}],"imports":[{"note":"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.","wrong":"const server = require('rollup-plugin-server')","symbol":"server","correct":"import server from 'rollup-plugin-server'"},{"note":"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.","wrong":"server({ contentBase: ['dist'], open: 'true' })","symbol":"server","correct":"server({ open: true, contentBase: 'dist' })"},{"note":"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.","wrong":"ssl_key: 'server.key'","symbol":"ssl_key","correct":"import fs from 'fs'; /* ... */ ssl_key: fs.readFileSync('server.key')"}],"quickstart":{"code":"import server from 'rollup-plugin-server';\nimport path from 'path';\nimport fs from 'fs';\n\n// Create a dummy entry file for Rollup to process\nconst entryFilePath = path.resolve(__dirname, 'entry.js');\nfs.writeFileSync(entryFilePath, 'console.log(\"Hello from Rollup bundle!\");');\n\n// Create a dummy dist directory and an index.html\nconst distDirPath = path.resolve(__dirname, 'dist');\nif (!fs.existsSync(distDirPath)) {\n  fs.mkdirSync(distDirPath);\n}\nconst indexHtmlPath = path.join(distDirPath, 'index.html');\nfs.writeFileSync(indexHtmlPath, '<!DOCTYPE html>\\n<html><head><title>Rollup App</title></head><body><div id=\"app\"></div><script src=\"bundle.js\"></script></body></html>');\n\nexport default {\n  input: entryFilePath,\n  output: {\n    file: path.join(distDirPath, 'bundle.js'),\n    format: 'esm'\n  },\n  plugins: [\n    server({\n      open: true, // Automatically open the browser\n      verbose: true, // Show server address in console\n      contentBase: distDirPath, // Serve files from the 'dist' directory\n      host: 'localhost',\n      port: 10001,\n      historyApiFallback: true // Serve index.html for 404s\n    })\n  ]\n};","lang":"javascript","description":"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`."},"warnings":[{"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.","message":"The 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.","severity":"gotcha","affected_versions":"<1.0"},{"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')`.","message":"When 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"If 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"The 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`.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"The configured server port (e.g., 10001) is already being used by another application or a previous instance of your development server.","error":"Error: listen EADDRINUSE: address already in use :::10001"},{"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.","cause":"The `ssl_key` or `ssl_cert` option in your server configuration points to a file that does not exist at the specified path.","error":"ENOENT: no such file or directory, open 'path/to/server.key'"},{"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.","cause":"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.","error":"RollupError: Could not resolve entry.js"}],"ecosystem":"npm"}