npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollup-plugin-dev

v2.0.5

Published

a development server for rollup

Downloads

17,421

Readme

rollup-plugin-dev

a development server for rollup

a screenshot of this plugin running

why this plugin?

compared to other plugins, this plugin:

  • uses Fastify to provide the server and implement features
    • while this means there are dependencies, it should also be trivial to add/modify to suit individual needs (see extend option below!)
  • has additional features that may be useful
    • detailed logging of requests (see screenshot)
    • full proxy support
    • support for a basepath in the URL
    • will automatically turn itself off when watch mode isn't enabled

install

npm install --save-dev rollup-plugin-dev
pnpm add --save-dev rollup-plugin-dev

use

import dev from 'rollup-plugin-dev'

export default {
  plugins: [
    dev()
  ]
}

options

dirs

directories to serve static files from

example: dev('dist') example: dev({ dirs: ['dist', 'lib'] }) default: __dirname

when no other options are needed, a shortcut is available to specify one folder

basePath

prefix all served files with a base path - e.g. serve from /static instead of /

example: dev({ basePath: '/static' }) default: /

silent

will silence all log messages, as well as the warning printed when rollup is started outside of watch mode

example: dev({ silent: true }) default: false

proxy

proxy a path to an upstream service

example: dev({ proxy: [{ from: '/api', to: 'http://localhost:9000/resources' }] }) example: dev({ proxy: [{ from: '/api', to: 'http://localhost:9000/resources', opts: { preHandler: myPreHandler } }] }) default: undefined

opts can contain any valid options for fastify-http-proxy

spa

serve a fallback page (for single-page apps)

example: dev({ spa: true }) // will serve index.html example: dev({ spa: 'path/to/fallback.html' }) default: false

if a path is provided, it should be relative to one of the dirs being served

the fallback file must reside in one of the dirs being served

port

the port the server should listen on

example: dev({ port: 3000 }) default: 8080

the server will automatically listen on the first available port after 8080 if the specified/default port is taken

host

the host the server should listen on

example: dev({ host: '0.0.0.0' }) default: localhost

force

force the server to start, even if rollup isn't in watch mode

example: dev({ force: true }) default: false

dirname

the path to resolve any relative dirs from

example: dev({ dirname: '/Users/MyUser/Development/my-project' }) default: undefined

this is generally not needed if one is running Rollup from package.json's scripts

server

modify options the Fastify server is booted with - accepts any valid Fastify server attribute

example: dev({ server: { connectionTimeout: 3000 } }) default: see config.js and the serverDefaults export

here be dragons - because modifying these options can wildly change server behavior, this is supported on an 'as is' basis only

extend

enables full customization of the dev server, expects a Fastify plugin

example: dev({ extend: fp(async (server) => server.register(myPlugin)) }) default: undefined

onListen

this is a callback that runs after the server has started

example: dev({ onListen(server) { server.log.info('Hello world') } default: undefined