V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
sewer
V2EX  ›  程序员

第一次用 v2, 可能没有注意, 信口开河,所以重开一贴,介绍下 create-muguet-lib

  •  
  •   sewer · 2019-08-10 08:32:54 +08:00 · 2047 次点击
    这是一个创建于 1714 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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
    • npm run eslint

      • auto fix tsx, ts, js, jsx, but some problems can't be fixed eslint
    • npm run changelog

    例子

    1. create-muguet-lib app (不能含有 react)
    2. npm install 安装依赖

    3. 注意

    1. 预加载处理器使用 scss
    2. ci 使用 travis
    3. 覆盖率使用 codecov
    4. 测试单元用 jest + enzyme 默认开启 snaptshot
    5. .script/config.json 更改一些默认设置

    4. 开发状态

    • [x] 库打包
    • [x] 文档网站打包
    • [x] 测试单元
    • [ ] 自定义使用库

    hub 链接 https://github.com/sewerganger/create-muguet-lib

    4 条回复    2019-08-10 18:50:10 +08:00
    admc
        1
    admc  
       2019-08-10 11:05:33 +08:00
    顶,虽然我用不着=。=
    codermagefox
        2
    codermagefox  
       2019-08-10 11:22:04 +08:00 via Android
    也写过类似的,感觉....用处不是很大
    sewer
        3
    sewer  
    OP
       2019-08-10 14:46:50 +08:00
    @codermagefox 这个脚手架不仅可以写 app 还能打包组件库呕, 我还加了很多工具, 你可以 npm 试一下, 当然正式开发还是 create-react-app
    oxogenesis
        4
    oxogenesis  
       2019-08-10 18:50:10 +08:00
    没事没事,知不合适能调整,善莫大焉
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2771 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 12:39 · PVG 20:39 · LAX 05:39 · JFK 08:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.