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-serverVerified import paths — ran on the pinned version, not inferred.
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`.
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.
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')`.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.
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.
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.
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.
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.