简体   繁体   中英

Include files on npm package but not on the git repo

我有一个相当简单的问题,是否可以在npm版本中包含工件(文件),但要避免将它们包含在git repo中(我想结合使用.npmignore.gitignore )?

Yes - this is absolutely possible.

The way that npm handles this is during publish as follows:

  1. Check if there is an .npmignore file present. If yes, exclude those files from the release. If not, fallback to step 2.

  2. ( optional ) Check if there is a .gitignore file present. If yes, exclude those files from the release.

So, if you want to keep everything in your npm release, but avoid pushing them to your git repository, all you need to do is put those files in .gitignore and create an empty .npmignore file.

This way, npm won't try to fallback to .gitignore .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM