uxiu-cli
v0.9.0-beta.12
Published
快速创建 koa 项目工具
Readme
安装 cli 工具
pnpm i -g uxiu-cli
# or
npm i -g uxiu-cli
# 使用以下方式临时运行
pnpx uxiu-cli
# or
npx uxiu-cli命令使用
uxiu-cli [command] [options] [value]
# or 使用 = 传值 (help命令除外)
uxiu-cli [command] [options]=[value]
# 传递多个示例
uxiu-cli build -c=./dir1 -c=./file1查看版本号
uxiu-cli -v
# or
uxiu-cli version获取帮助
help 命令特殊, 不可使用 = 传值
uxiu-cli -h
# or
uxiu-cli help
# or 获取具体命令帮助
uxiu-cli -h [command]创建项目
name 别名 -n 项目名称
root 别名 -r 创建项目的根路径, 默认为
命令运行位置
示例
uxiu-cli
# or
uxiu-cli create -n [name]打包项目
pwd 别名 -p 配置文件运行根目录, 默认为
命令运行位置entry 别名 -e 项目入口文件路径, 默认为
./src/index.tsoutDir 别名 -o 打包输出路径, 默认为
./distformat 别名 -f 输出格式 默认为
esmplatform 别名 -pl 运行平台, 默认值为
nodeunbundle 别名 -ub 不拆包, 默认为
truenodeProtocol 别名 -np node 内置模块添加
node:前缀, 默认为trueconfig 别名 -c 打包配置文件路径, 默认为
./uxiu-cli.config.ts
示例
uxiu-cli build打包配置文件
默认读取 ./uxiu-cli.config.ts
示例 1
// 借助 defineBuild() 函数获取类型提示
import { defineBuild } from 'uxiu-cli'
export default defineBuild({
// 书写配置
})tsdownOptions tsdown 选项, 该选项将覆盖 uxiu-cli 选项
event 事件
beforeBuild 打包前事件, 仅配置文件支持
hook:beforeBuild 打包前钩子函数(若返回 Promise 将进行等待), 仅配置文件支持
afterBuild 打包后事件, 仅配置文件支持
hook:afterBuild 打包后钩子函数(若返回 Promise 将进行等待), 仅配置文件支持
error 打包错误事件, 仅配置文件支持
hook:error 打包错误事件钩子函数(若返回 Promise 将进行等待), 仅配置文件支持
示例 2
// 借助 configToJSON5() 将代码配置转为静态 json5 配置
import { configToJSON5 } from 'uxiu-cli'
const json5Text = await configToJSON5(path)- path code 文件绝对路径
示例 3
// 使用 tsdown
import { tsdown } from 'uxiu-cli'
tsdown.build // tsdown 包