JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4743
  • Score
    100M100P100Q114901F
  • License MIT

a development server for rollup

Package Exports

  • rollup-plugin-dev

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rollup-plugin-dev) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

rollup-plugin-dev

a development server for rollup

a screenshot of this plugin running

why this plugin?

if you just want to serve a folder of assets, or need only a couple other features; you probably want rollup-plugin-serve

compared to rollup-plugin-serve, this plugin:

  • uses Koa 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 (with a notification) for your production builds

install

npm install --save-dev rollup-plugin-dev
yarn add --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 for this plugin, 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 access log messages, as well as the warning printed when rollup is started outside of watch mode

example: dev({ silent: true })
example: dev({ silent: 'very' }) // disables all output from this plugin
default: false

proxy

proxy a path to an upstream service

example: dev({ proxy: { '/v3/*': 'https://polyfill.io/' } })
example: dev({ proxy: { '/v3/*': ['https://polyfill.io/', { https: true }] } })
default: undefined

the value for a proxy can be either a string, or an array specifying the two arguments for koa-better-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

port

the port the server should listen on

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

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

extend

enables full customization of the dev server

example: dev({ extend(app, modules) { app.use(modules.router.get('/foo', myHandler)) } })
default: undefined

app is the Koa instance used for the server

modules available: