unitool
v1.1.3
Published
The Extension library build package based on Rollup's uniLib can also be used to build other libraries
Maintainers
Readme
unitool
简介
基于rollup的uniLib的扩展库构建打包工具,也可以用于构建其他库
The Extension library build package based on Rollup's uniLib can also be used to build other libraries
特性
- 支持typescript开发
- 可以导出iife,commonjs,systemjs等格式
- 将声明打包成单个dts声明文件
安装
npm install -D unitool使用
- 对于不需要全局变量名的
unitool build -f cjs - 需要全局变量名的,冒号: 后跟变量名(如果不写,自动从package.json中解析)
unitool build -f iife:xxx
更多使用可以参考 模板项目 package-template
构建配置项
在tsconfig.json中可以增加配置
dtsGenExclude 生成.d.ts文件时所要忽略的
比如 core包中的
"dtsGenExclude": [ "__tests__/**/*" ]忽略测试目录下的文件,不生成声明文件
externalTag 用来判断引用的模块是否做为外部引用(不编译进来) 因为packages内的A包,引用了B包,会把A和B的代码编译成一个js 参考:
"externalTag":"@helojo" 或 "externalTag":["@helojo"]
构建命令行参数
- '-w, --watch [watch]', '是否监视 默认false'
- '-e, --entry [entry]', '入口文件 默认src/index.ts'
- '-o, --output [output]', '输出文件 默认dist/index.js'
- '-f, --format [format]', '输出格式 默认cjs,可选iife,umd,es 如果是iife和umd 需要加: 冒号+全局变量名'
- '-d, --types-dir [typesDir]', '声明文件输出目录 默认 dist/types'
- '-s, --source-dirs [sourceDirs]', '源码目录数组,默认[src],写 src,src2'
- '-u, --unRemoveComments [unRemoveComments]', '是否移除注释'
- '-t, --target [target]', '编译目标es标准,默认es5'
- '-m, --minify [minify]', '是否压缩,如果是将会输出.min.js'
