如何仅发布特定文件夹的内容? [英] How to publish contents only of a specific folder?

查看:38
本文介绍了如何仅发布特定文件夹的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我只想包含特定路径时如何简化 npm release?

How to streamline npm release when I want to include only specific path(s)?

我的存储库中有 ./src./dist 文件.我只想有效地发布 ./dist + ./package.json.

I have ./src and ./dist files in my repository. I want to effectively publish only the contents of ./dist + ./package.json.

使用 .npmignore 忽略 ./src 只会忽略 ./src 文件夹.我只想包含 ./dist 的内容,即现在用户需要执行 require('my-package/dist/something').我想让它require('my-package/something')../something 包含在 ./dist.

Using .npmignore to ignore ./src will simply ignore the ./src folder. I want to include only the contents of ./dist, i.e. now user would need to do require('my-package/dist/something'). I want to make it require('my-package/something'). ./something is contained in ./dist.

推荐答案

我目前的做法是,我创建了一个 bash 脚本:

The way I have done it at the moment is, I have created a bash script:

npm run build
cp package.json ./dist
# or, if you need to have package.json "main" entry different,
# e.g. for being able to use `npm link`, you need to replace "main" value:
# sed 's#"main": "./dist/index.js"#"main": "./index.js"#' package.json > ./dist/package.json
cd ./dist
npm publish

这篇关于如何仅发布特定文件夹的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆