Search code examples
angulardeploymentbuild

How to share code between two angular project?


I have two Angular projects. They will share some code like pipes, classes, utils, enums and so on.

They are now allowed to deploy to the public repository.

Also we don't have private repository.

I Knew maven can use install command to deploy builds into local maven repository.

Is it a good idea to let angular projects did the same way?

How do you share code between two angular projects in this situation?


Solution

  • Multiple projects and libraries can share the same angular workspace. If you look at the 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.

    Then you can put your shared code into libraries. You can create a library with ng generate library command.