hx-ths-cli
v1.3.7
Published
一个简单的替换前端项目中的相对地址为绝对地址
Downloads
3
Readme
ths-cli
一个简单的cdn地址替换命令行工具(适用ths)
工具会对页面中的css,js,以及图片地址进行cdn地址转换,需要在link,script标签添加cdn即可(例如:<link href="./styles/index.css" cdn>
)
js地址可以进行合并也可以针对某个js单独生成cdn地址,如需单独生成才需要在script标签中添加single(例如:<script src="./scripts/index.js" single></script>
),出现single就不必在加cdn,默认会对添加 cdn属性值相等的的script标签 按顺序进行合并。如果添加cdn的标签只有一个则不会使用合并语法。
工具会自动修改css和html文件中的图片引用地址,但不会处理js中的地址
会对js,css文件进行压缩,会保留原始文件,上传静态资源服务器时只需上传压缩文件即可。
安装
npm install ths-cli -g
使用
使用 ths-cli cdn 执行默认的cdn替换
使用 ths-cli cdn -t 20180202指定cdn时间戳
使用 ths-cli init 初始化配置文件
使用 ths-cli create 创建开发目录
使用 ths-cli test 测试替换的cdn地址
#配置文件有三个配置项
cdn --> cdn地址
build --> 对应打包后的目录,不能与当前目录中的文件夹同名
ignore --> 打包时需要忽略的目录
1.3.7 新增功能
- 创建env.config.json文件,为内网ci构建做准备
- 命令行增加-d 或者--default参数,跳过可交互式命令行,确认默认配置打包例如:
hx-ths-cli cdn --default -t 20220421 或
hx-ths-cli cdn -d -t 20220421