create-muguet-lib 是我为了开发muguet-ui而开发的 react 脚手架,具有网站和 ui 库共同开发的功能。
另外要星星,现在感觉也是真的。。。昨晚发帖前没有过脑子。引起了众怒。 还有那个博客的文章是我同学写的,我复制了点,跟他讲好了。写文章太浪费时间了,这是我的知乎的文章 https://www.zhihu.com/people/mrno-64/posts 第一次玩 v2, 以后文章更新也会在 v2 更新了, 应为我感觉 v2 比较有氛围。
1. 安装
npm i create-muguet-lib -g
2. 使用方法
全局命令
Usage: cli [options]
Options:
-v, --version output the version number
-a, --author <name> add Author
-l, --license <name> add License
-h, --help output usage information
模板中的命令
-
npm start
- 打开文档开发环境,提供组件开发和文档网站开发的 development 环境
-
npm run lib
- 使用 babel 编译组件库 到 release/lib 文件夹下 并生成 d.ts, main 字段指向 release/lib/exports.js
-
npm run es
- tsc 直接编译到 release/es 文件夹下 并生成 d.ts module 字段指向 release/es/exports.js
-
npm run dist
- webpack 打包 到 release/dist 文件夹下
-
npm run app
- webpack 打包文档网站
-
npm run release
- 发布同时进行 lib es dist app
-
npm run dts:es
- 向 release 的 es 中写入 d.ts
-
npm run dts:lib
- 向 release 的 lib 中写入 d.ts
-
npm run dts
- 向 release 的 es 和 lib 中写入 d.ts
-
npm run scss:watch
- 监听并编译 scss 支持 compass
-
npm run scss
- 编译 scss
-
npm run test
- 使用
jest + enzyme, 在项目中随意建立一个__tests__否则运行此命令报错,Snapshot默认使用
- 使用
-
npm run cz:init
- 初始化commitizen, 它会格式化你的
commit message, 使用git cz代替git commit -m,在 commit 完后会自动运行 eslint husky and lint-staged
- 初始化commitizen, 它会格式化你的
-
npm run eslint
- auto fix tsx, ts, js, jsx, but some problems can't be fixed eslint
-
npm run changelog
例子
- create-muguet-lib app (不能含有 react)
- npm install 安装依赖
3. 注意
- 预加载处理器使用 scss
- ci 使用 travis
- 覆盖率使用 codecov
- 测试单元用 jest + enzyme 默认开启 snaptshot
- 在
.script/config.json更改一些默认设置
4. 开发状态
- [x] 库打包
- [x] 文档网站打包
- [x] 测试单元
- [ ] 自定义使用库