• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

pearofducks/rollup-plugin-dev: development server for rollup with additional log ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

pearofducks/rollup-plugin-dev

开源软件地址:

https://github.com/pearofducks/rollup-plugin-dev

开源编程语言:

JavaScript 99.9%

开源软件介绍:

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap