Bal*_*des 2 gitignore npm npm-publish
情况如下
我有一个.gitignore
文件:
node_modules
npm-debug.log
/index.js # this is a build output, I don't want it in the repo
Run Code Online (Sandbox Code Playgroud)
和一个package.json
文件(只是相关部分):
{
"main": "index.js",
"files": [
"index.js", // however I want this in the npm package
"readme.md",
"package.json"
],
"scripts": {
"build": "rollup -c rollup.config.js", // this builds index.js ...
"lint": "eslint **/*.js --config .eslintrc",
"test": "jest --no-cache",
"prepublish": "npm run lint && npm test && npm run build" // ...before publishing
}
}
Run Code Online (Sandbox Code Playgroud)
当我发布第一个版本时,index.js
被省略,只有 和readme.md
被package.json
正确发布。我唯一可以假设的是,这.gitignore
会导致这种情况,因为根据文档,如果后者不存在,.gitignore
则替换.npmignore
(或者可能两者一起使用,不知道)。
那么有没有办法不将该文件放在 git 存储库中,而是将其放在 npm 包中呢?
设法通过添加文件来解决这个问题.npmignore
:
# all the crap that's not neccessary for the npm module to work
node_modules
src
test
.babelrc
.eslintignore
.eslintrc
.gitignore
.npmignore
.travis.yml
rollup.config.js
Run Code Online (Sandbox Code Playgroud)
并files
从 中完全删除该属性package.json
。
归档时间: |
|
查看次数: |
729 次 |
最近记录: |