当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

rollup-plugin-dev

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 韦熙云
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

rollup-plugin-dev

a development server for rollup

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
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, 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

  • `@rollup/plugin-terser` 是一个用于压缩 JavaScript 代码的插件。使用该插件可以大幅减小代码体积,提高应用程序的性能。以下是 `@rollup/plugin-terser` 的用法步骤: 1. 安装 `@rollup/plugin-terser` 插件 使用以下命令安装 `@rollup/plugin-terser` 插件: ```bash npm install

  • 1、错误描述 G:\HBuilderXWork\vue-next>npm run dev > @3.0.0-rc.5 dev G:\HBuilderXWork\vue-next > node scripts/dev.js [!] Error: Cannot find module '@rollup/plugin-replace' Error: Cannot find module '@roll

  • 学习记录-rollup 目录 学习记录-rollup 一、搭建一个基础项目 二、插件支持 三、导出为全局库 四、我如何在使用 CommonJS 模块的 Node.js 中使用 Rollup?​ 五、rollup官方模板项目 @rollup/plugin-alias插件 Rollup 是一个 JavaScript 模块打包工具,可以将多个小的代码片段编译为完整的库和应用。与传统的 CommonJS

  • 介绍 如果需要直接开发项目,webpack 是合适的,它将图片、js、css等视作资源,但本身比较笨重,会稍微增大代码的体积; 如果要开发js库,就可以使用配置简单且轻量的 rollup 了。 特性 能够支持模块化开发,使开发者能够使用 ES6 模块的方式编写代码; 支持 ES6 模块,能够从库中单独引入需要的函数; 拥有 Tree-Shaking 的能力,能够对代码进行静态分析,并剔除未使用到的

  • 基于 rollup 搭建 vue 的组件 简单的说,因为对很多类型的静态资源处理没有 webpack 强大,但是基于 Tree-shaking 原理用来打包 lib的话,打出来的包,干净,小。所以 rollup 比较适合打包小型的 lib 库,不适合用来做开发。 1. 项目传送门 主要流程和包 2. 初始化项目 npm init -y npm i -D rollup 3. 添加配置文件 // r

  • rollup 总结 什么是 rollup? rollup 是一个 JavaScript 模块打包器,在功能上要完成的事和 webpack 性质一样,就是将小块代码编译成大块复杂的代码,例如 library 或应用程序。在平时开发应用程序时,我们基本上选择用 webpack,相比之下,rollup.js 更多是用于 library 打包,我们熟悉的 vue、react、vuex、vue-router

  • @vue/cli-plugin-pwa vue-cli 的 pwa 插件 该插件加入的 service worker 只会在生产环境下 (即只在运行 npm run build 或 yarn build 时) 开启。在开发环境下开启 service worker 并不推荐,因为它会导致之前的缓存资源被使用而未包含最新的本地改变。 取而代之的是,在开发环境下引入 noopServiceWork

  • 前言 一般我们在开发中大多数会使用 console.log 去打印一些数据, 以便于开发调试。到了生产中这些 console.log 就显得有点多余,且容易暴露一些重要信息。所以我们在发生产的时候有必要将 console.log 等打印信息给去除。 我们可以使用 webpack 去帮助我们实现这个效果,免去了手动删除这种繁琐的操作。 terser-webpack-plugin 从webpack官网

 相关资料
  • 我正在尝试使用rollup-plugin-multi-entry和rollup-plugin-uglify将相当多的JavaScript文件捆绑到一个缩小的文件中。我是缩小文件的新手,所以唯一引起注意的是,当我捆绑多个文件并将其缩小时,与捆绑单个文件并缩小该文件时相比,我的IDE主题不会改变代码的颜色。 单文件工作: 多个文件不起作用: 我使用的是一个汇总配置文件,当我在节点中运行脚本时,它不会抛

  • Rollup 是 JavaScript 的模块 bundler,可将一小段代码编译为更大或更复杂的内容,例如库或应用程序。 它对 JavaScript 的 ES6 修订版中包含的代码模块使用了新的标准化格式,而不是先前的特殊解决方案(例如 CommonJS 和 AMD)。ES 模块使用户可以自由,无缝地结合自己喜欢的库中最有用的单个函数。

  • DEPRECATED We are deprecating this template in favor of the webpack one. Some things may have changed and I haven't tested this template in a while. Check the Groceries Vue app for an example of a wor

  • 似乎我们可以使用typescript来编写汇总配置文件。比如说,我可以创建一个名为,包含以下内容: 如果我以。 但如果我在其中使用一些打字: 它将报告以下错误: 有可能让它工作吗?我试着用ts节点

  • 使用汇总打包Vue组件时,会出现此错误: 卷起来。配置。js: 按钮vue: 有解决办法吗? 所以我找到了一个更好的方法: 最好使用vue sfc汇总来打包vue组件。

  • 我正在使用来帮助解决我的LitElement项目中的svg导入,推荐如下:https://github.com/rollup/plugins.我还在custom.d.ts中声明了'*. svg'模块,因为我使用的是打字稿。 问题是我不知道如何在rollup的捆绑输出中包含SVG文件,这意味着我的浏览器以后无法导入这些文件,我在控制台中看到401个错误。为了暂时解决这个问题,我只需在需要在自定义Li