Direct from the Angular Guide Workspace and project file structure - Multiple projects
Multiple projects
A multi-project workspace is suitable for an enterprise that uses a single repository and global configuration for all Angular projects (the "monorepo" model). A multi-project workspace also supports library development.
Setting up for a multi-project workspace
If you intend to have multiple projects in a workspace, you can skip the initial application generation when you create the workspace, and give the workspace a unique name. The following command creates a workspace with all of the workspace-wide configuration files, but no root-level application.
ng new my-workspace --createApplication="false"
You can then generate apps and libraries with names that are unique within the workspace.
cd my-workspace
ng generate application my-first-app
Multiple project file structure
The first explicitly generated application goes into the projects/
folder along with all other projects in the workspace. Newly generated libraries are also added under projects/
. When you create projects this way, the file structure of the workspace is entirely consistent with the structure of the workspace configuration file, angular.json
.
my-workspace/
... (workspace-wide config files)
projects/ (generated applications and libraries)
my-first-app/ --(an explicitly generated application)
... --(application-specific config)
e2e/ ----(corresponding e2e tests)
src/ ----(e2e tests source)
... ----(e2e-specific config)
src/ --(source and support files for application)
my-lib/ --(a generated library)
... --(library-specific config)
src/ --source and support files for library)
Library project files
When you generate a library using the CLI (with a command such as ng generate library my-lib
), the generated files go into the projects/ folder of the workspace. For more information about creating your own libraries, see Creating Libraries.
Libraries (unlike applications and their associated e2e projects) have their own package.json
configuration files.
Under the projects/
folder, the my-lib
folder contains your library code.
It continues on in a table to describe library project files and their purpose. I'd suggest reading up further on the documentation above and associated links as it is well documented and might get you up and running quickly.
To run multiple Angular apps on different ports just open another terminal and run ng serve --port 1234
for each app. See Angular(2) - Running two projects with CLI