gpt4 book ai didi

lerna - 如何在 monorepo 中仅打包 dist 文件夹

转载 作者:行者123 更新时间:2023-12-04 12:35:59 24 4
gpt4 key购买 nike

我在我的 monorepo 中使用 lerna 和 yarn 工作区。包结构如下所示:

root
`--- packages
|--- pkg1
| |--- src
| | `--- index.ts
| `--- dist
| `--- index.js
`--- pkg2
|--- src
| `--- index.ts
`--- dist
`--- index.js
  • src文件夹被编译成 dist文件夹。
  • 从每个包中,我只想发布 dist文件夹,以便导入工作无需 main package.json 中的条目指向 dist文件夹。使用 lerna 很容易做到这一点:lerna publish --contents dist .

  • 这适用于需要使用此 repo 的外部项目,但它不适用于 repo 本身。例如,如果 pkg2 , 取决于 pkg1 ,它会在 pkg1/index.js 处寻找 pkg1 的 index.js 文件而实际上编译版本位于 pkg1/dist/index.js 下.我怎样才能使这项工作?

    附言我在 material-ui 之类的存储库中看到了这项工作,但我无法解释它在那里是如何工作的!

    最佳答案

    查看 package.json 文件的"file"字段 https://docs.npmjs.com/files/package.json#files

    The "files" field is an array of files to include in your project. If you name a folder in the array, then it will also include the files inside that folder. (Unless they would be ignored by another rule.)

    关于lerna - 如何在 monorepo 中仅打包 dist 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61669420/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com