father库说明
GitHub:https://github.com/umijs/father
升级迁移
教程使用father v1,版本较老,可参考下面的教程升级
father 4升级教程
安装
yarn add father
项目配置
0、项目结构
1、配置fatherrc.js
2、配置src/index.js
3、配置components/index.tsx
4、运行:father build
运行后项目文件夹内会生成一个es
文件目录,里面就是打包好的代码库
发布代码包
(1)发布到私有GitHub仓库
// 正常的git提交代码
git add .
git commit ""
git push
(2)发布到npm
// 这块博主暂时没有动手实践,所以可能有误
npm init
npm login
npm publish
在其他项目中使用
(1)从私有GitHub仓库安装
1、配置 package.json
{
"dependencies": {
// git + ssh
"tiw-monitor-lib": "git+ssh://${git仓库ssh地址}"
// git + http
"tiw-monitor-lib": "git+http://${git仓库http地址}"
}
}
2、执行安装
npm install tiw-monitor-lib --save
(2)从npm安装
直接执行安装即可,npm会自动从远程拉回代码包
npm install tiw-monitor-lib --save