如何在两个 angular 项目之间共享代码?
How to share code between two angular project?
我有两个 Angular 项目。他们将共享一些代码,如管道、类、实用程序、枚举等。
他们现在可以部署到 public 存储库。
我们也没有私人仓库。
我知道 maven 可以使用 install 命令将构建部署到本地 maven 存储库。
让 angular 个项目以同样的方式做是个好主意吗?
在这种情况下,您如何在两个 angular 项目之间共享代码?
多个项目和库可以共享同一个 angular 工作区。如果您查看 angular cli documentation:
If you plan to have multiple applications in the workspace, you can create an empty workspace by setting the --createApplication
option to false. You can then use ng generate application
to create an initial application. This allows a workspace name different from the initial app name, and ensures that all applications reside in the /projects
subfolder, matching the structure of the configuration file.
那你就可以把你的分享码放到libraries里了。您可以使用 ng generate library
命令创建库。
我有两个 Angular 项目。他们将共享一些代码,如管道、类、实用程序、枚举等。
他们现在可以部署到 public 存储库。
我们也没有私人仓库。
我知道 maven 可以使用 install 命令将构建部署到本地 maven 存储库。
让 angular 个项目以同样的方式做是个好主意吗?
在这种情况下,您如何在两个 angular 项目之间共享代码?
多个项目和库可以共享同一个 angular 工作区。如果您查看 angular cli documentation:
If you plan to have multiple applications in the workspace, you can create an empty workspace by setting the
--createApplication
option to false. You can then useng generate application
to create an initial application. This allows a workspace name different from the initial app name, and ensures that all applications reside in the/projects
subfolder, matching the structure of the configuration file.
那你就可以把你的分享码放到libraries里了。您可以使用 ng generate library
命令创建库。