参考:
redux
reach-router
rollup-starter-lib
rollup-starter-app
roller-cli
create-react-library

一、安装
npm install --global rollup 二、命令:
rollup -c
默认指向rollup.config.js import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import image from 'rollup-plugin-image';
import sizes from 'rollup-plugin-sizes';
// import env from 'rollup-plugin-env';
// import uglify from 'rollup-plugin-uglify'; import pkg from './package.json'; const external = Object.keys(pkg.dependencies || {}); export default {
input: 'src/index.js',
output: [
{
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
},
],
plugins: [
// env({ NODE_ENV: 'production' }),
peerDepsExternal(),
postcss({
modules: true,
}),
image(),
babel({
exclude: 'node_modules/**', }),
resolve(),
commonjs({
include: 'node_modules/**',
namedExports: {
'node_modules/react/index.js': ['Component', 'PureComponent', 'Children', 'createElement'],
},
}),
// uglify(),
sizes({ details: true }),
],
external, // dependencies 内 不需要打包进去,运行时加载
}; 三、
rollyup 默认将相对路径加载, 如果想加载node_module 需要用rollup-plugin-node-resolve.
Rollup will only resolve relative module IDs by default.
If you do want to include the module in your bundle, you need to tell Rollup how to find it. In most cases, this is a question of using rollup-plugin-node-resolve. 四
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use rollup-plugin-commonjs: 五、
rollup-plugin-babel
在Babel实际编译代码之前,需要进行配置。 创建一个新文件src/.babelrc:

最新文章

  1. jQuery对表单、表格的操作及更多应用
  2. 在OSX和Windows版本Docker上运行GUI程序
  3. Github上安卓榜排名第2的程序员教你如何学习【转载,侵删】
  4. hash算法总结收集
  5. SharePoint 读取 Site Columns 的数据并绑定到DropdownList
  6. uva 1639--精度处理方法之取对数(uva 1639)
  7. c#4
  8. sdk manager更新失败,显示Download interrupted: read timed out,应该如何解决?
  9. 设置控件Enable=false,控件颜色不变
  10. 模拟Struts2框架Action的实现
  11. 夏令营讲课内容整理 Day 6 Part 3.
  12. C语言结构体作业
  13. delphi开源JWT
  14. mac安装gcc
  15. STM32外设地址查询
  16. 2018 AICCSA Programming Contest
  17. 朴素贝叶斯分类器(Naive Bayes)
  18. 通过jquery,从json中读取数据追加到html中
  19. 关于NaN
  20. SQl查询数据库库名,表名、表的列名

热门文章

  1. Asp.net的DataGrid实现列冻结(C#)
  2. 基于C#&.net2.0的windows服务创建与安装
  3. Java开发笔记(四十九)关键字super的用法
  4. Dynamics 365创建用户提示:您正在尝试使用已由其他用户使用的域登录来创建用户。如何解决。
  5. C# 一款属于自己的音乐播放器
  6. java新知识系列 三
  7. [Python][小知识][NO.5] 使用 Pyinstaller 打包成.exe文件
  8. 跨平台 webapp 开发技术之 Hybrid App
  9. 【自动化测试&爬虫系列】Selenium Webdriver
  10. SQL Server Log Shipping学习总结