当项目作为依赖项包含时,控制节点模块的内容
Control content of node module when included as dependency by a project
假设我有一个节点项目 'A',其中包含一个 JS 文件、10 个资源文件和一些测试文件。
还有一个项目'B'依赖于项目'A'的JS文件。因此,它将它作为依赖项包含在 package.json 中,如:
"dependencies": {
"A": "git+https://github.com/repo/A.git"
}
但这也会尝试在 node_modules 文件夹中获取所有不需要的文件,例如项目 'A' 的资源和测试文件。
有没有一种方法可以让我在 'A' 的 package.json 中控制如果包含为依赖项要公开哪些文件?
我相信 .npmignore 是您所需要的。请参阅 Keeping files out of your package
假设我有一个节点项目 'A',其中包含一个 JS 文件、10 个资源文件和一些测试文件。
还有一个项目'B'依赖于项目'A'的JS文件。因此,它将它作为依赖项包含在 package.json 中,如:
"dependencies": {
"A": "git+https://github.com/repo/A.git"
}
但这也会尝试在 node_modules 文件夹中获取所有不需要的文件,例如项目 'A' 的资源和测试文件。
有没有一种方法可以让我在 'A' 的 package.json 中控制如果包含为依赖项要公开哪些文件?
我相信 .npmignore 是您所需要的。请参阅 Keeping files out of your package