angular - 如何从 Angular 库中公开 bin javascript 文件
问题描述
我正在创建一个库,它向用户公开一些 bin 脚本,然后他可以在他的构建过程中使用这些脚本。但是,我对将此类脚本暴露给dist
包感到不安。
我的 package.json 看起来像这样:
{
"name": "my-app",
"bin": {
"foobar": "./bin/custom-build.js"
}
}
结构如下所示:
当我运行构建时,custom-build.js
在目录中dist
找不到。我的问题是如何公开这些文件?
解决方案
您应该将它们添加到angular.json
. 它们将合并为scripts.js
in dist
。
{
"projects": {
"your-project-name": {
"architect": {
"build": {
"options": {
"scripts": [
"path/to/your/lib1.js",
"path/to/your/lib2.js"
]
}
}
}
}
}
}
编辑:
在 Angular CLI 中没有复制文件的选项。您可以使用外部工具存档,例如 bash 脚本、gulp https://gulpjs.com/
然后将其合并到您的package.js
{
"scripts": {
"build": "ng build && gulp bundle"
}
}
推荐阅读
- react-native - 如何获取从添加到购物车页面传递的产品的 redux 存储数据
- vim - 在vim中通过运动覆盖粘贴
- azure-devops - Azure DevOps ClickOnce Build&Release publish.htm missing
- node.js - Firebase 远程配置不适用于单元测试中的 NodeJS
- prestashop - actionValidateCustomerAddressFormAfter 在 Prestashop 的表单验证之前触发钩子
- mobile - 2020年跨平台APP开发情况如何?
- azure - 如何将文件从工件目录复制到 azure app 服务?
- c# - 在 .NET 中创建和处置 KeyVaultClient
- oop - 我们可以说调用任何普通方法也称为抽象,因为它提供了它的功能并隐藏了实现吗?
- r - Read UTF-8 text in R