rollup学习整理-1-api详解
来源:互联网 发布:优质的企业排名优化 编辑:程序博客网 时间:2024/05/16 19:52
RollUP 学习整理
创建项目,安装 Rollup
mkdir rollup-demo cd rollup-demo mkdir src #创建源码目录 npm init sudo npm install --save-dev rollup #安装Rollup
创建配置文件
项目根目录下,创建
rollup.config.js
配置文件
export default { input: './src/main.js', output: { file: './dist/js/bundle.js', format: 'iife', name: 'MyBundle', }, plugins: [], externals: [], globals: { jquery: '$' }, banner: 'const a = 6; console.log(a);', footer: '/* this is footer */', intro: 'const a = 6;', outro: '/* this is outro */', cache: true, sourcemap: 'true', strict: true, }
配置文件参数详解
1. input
项目入口
input: './src/main.js', // 项目入口
2. output
项目输出配置
output: { // 编译后文件 file: './dist/js/bundle.js', // 打包后的路径 format: 'iife', // 生成包的格式规范 包括 amd umd cjs es iife name: 'MyBundle', // 打包后的包名 iife / umd包 // -> var MyBundle = (function () {... },
3. plugins
插件项
plugins: [ resolve(), commonjs() ]
4. externals
外部引用 防止将某些 import 的包(package)打包到 bundle 中,而是在运行时(runtime)再去从外部获取这些扩展依赖, 一般用于library开发,以下是官网的例子
external: [ 'some-externally-required-library', path.resolve( './src/some-local-file-that-should-not-be-bundled.js' ) ]
5. globals
全局模块 提供将外部模块ID转换为全局模块的功能
globals: { // 全局模块 提供将外部模块ID转换为全局模块的功能 jquery: '$' },
6. banner / footer
前置 / 追加 到文件束,最终添加到了生成包的外部,可以是代码也可以是注释
banner: 'const a = 6; console.log(a);', footer: '/* this is footer */',
结果
const a = 6; console.log(a); // banner (function () { 'use strict'; ... }()); /* this is footer */ // footer
7. intro / outro
与banner / footer 差不多,但是内容最终添加到了生成包的内部
intro: 'const a = 6;', outro: '/* this is outro */',
结果
(function () { 'use strict'; const a = 6; // intro ... /* this is outro */ // outro }());
8. cache
缓存
cache: true, // 缓存
9. sourcemap
- true: 会创建单独的 sourcemap 文件
- inline: sourcemap将作为数据URI附加到生成的output文件中。
sourcemap: 'true',
10. strict
strict: true
严格模式,默认开启
相关文章
- rollup学习整理-1-api详解
- rollup学习整理-2-插件详解
阅读全文
0 0
- rollup学习整理-1-api详解
- rollup学习整理-2-插件详解
- JavaWeb API整理学习
- MYSQL API之 WITH ROLLUP
- iScroll API 整理学习笔记
- GDB学习整理1--Gcc编译详解
- Unity3D API整理1
- CUBE、ROLLUP 、COMPUTE 使用详解
- CUBE、ROLLUP 、COMPUTE 使用详解
- RollUP
- Drop and Drag API学习与整理
- 4、facebook Marketing API 学习整理
- Vue 常用API整理 1
- [API学习]windows数据结构详解
- OpenGL学习之API详解
- SQL CUBE、ROLLUP 、COMPUTE 使用详解
- oracle 中 rollup、cube、grouping 使用详解
- oracle group by rollup用法详解
- SSh框架整合
- python scrapy request页面抓取异常报错及处理
- 森林 树--》二叉树的转换
- git 设置免登陆ssh秘钥
- 正则表达式大全
- rollup学习整理-1-api详解
- Tomcat配置问题
- Mybatis(一)
- ElasticSearch5.X聚合-条形图(四)
- 对gulp构建工具的一些常用功能的总结
- iOS开发-__func__的使用
- 记一次虚拟机复制迁移到异机启动报could not open disk image /123.img: Invalid argument 错误
- mysql 高可用之MySQL-MMM
- 数据中心联盟第五批大数据产品评测结果出炉,腾讯云大数据斩获多个奖项