在我的 package.json 文件中,我在“脚本”中有很多命令,如下面的代码。
"scripts" {
"script1": "command example",
"script2": "command example",
"script3": "command example",
"script4": "command example",
"script5": "command example",
"script6": "command example",
"script7": "command example",
...
}
有没有办法将这些命令移动到另一个文件?
例如,我正在考虑将它们移动到类似 bin/commands.js
的文件中。
最佳答案
这是一个常见问题,让您的 package.json 因脚本过多而变得臃肿。 Kent Dodds 构建了一个非常好的解决方案,称为 NPS (npm-package-scripts)。不幸的是,这个问题的解决方案并不多。
PRO:您在 js 文件中定义脚本,这样您就拥有更大的灵 active ,减少 package.json 中的困惑,良好的社区支持。
缺点:不多只是命令不同(nps vs npm)
关于javascript - 为 "scripts"使用单独的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55566821/