In accordance with the Angular Style Guide and the Angular CLI convention for naming generated elements in the file system, use a hyphenated, lowercase structure (kebab-case) for all file and folder names.
Do not use camelCase, especially since it can lead to problems when working with different operating systems.
Some systems, such as Windows, are case-insensitive regarding file and folder naming.
This folder layout fits the specific needs of this project.
Key considerations included defining a set of rules for where to place components and other artifacts to ease development, customization, and bundling to achieve fast loading.
This structure deviates from the general guidelines of Angular CLI.
However, custom CLI schematics let you easily add all artifacts to the project.
Additionally, activate the custom ESLint rules project-structure and ban-imports-file-pattern to receive feedback when adding files to the project.
The basic structure looks like this:
src
├─ app
| ├─ core
| | ├─ models
| | ├─ store
| | ├─ facades
| | ├─ utils
| | └─ ...
| ├─ extensions
| | ├─ foo
| | └─ bar
| ├─ pages
| ├─ shared
| └─ shell
├─ assets
├─ environments
└─ themeThe src/app folder contains all TypeScript code (sources and tests) and HTML templates:
core contains all configuration and utility code for the main B2C application.
core/models contains models for all data entities for the B2C store.core/utils contains all utility functions that are used in multiple cases.core/store contains the main State Management; core/facades contains facades for accessing the state in the application.shell contains the synchronously loaded application shell (header and footer).pages contains a flat list of folders for page modules and components that are used only on the corresponding page.shared contains code that is shared across multiple modules and pages.extensions contains extension modules mainly for B2B features that have minimal touch points with the B2C store. Each module (foo and bar) contains code that concerns only itself. The connection to the B2C store is implemented via lazy-loaded modules and components.The src/assets folder contains files that are statically served (pictures, mock data, fonts, localization, etc.).
The src/environments folder contains environment properties that are switched by Angular CLI, see Configuring application environments.
The src/theme folder contains styling files.
Place components only in
shared,shell, andpages.
Additional features that are not universally used are grouped into extensions to keep the main sources structured.
Each extension module can have multiple subfolders:
exports: components that lazily load additional componentspages: page modules and components used on this pageshared: components shared among pages for this extensionmodels: models specific for this extensionservices: services specific for this extensionutils: utility services and functions specific for this extensionstore: ngrx handling (State, Effects, Reducer, Actions, Selectors)facades: providing access to the state managementOptionally, additional subfolders for module-scoped artifacts are allowed:
All code of an extension resides in its folder, including small UI parts, such as a header link, and their styles.
Code outside the extension (shell, pages, shared) uses exclusively what the extension provides in exports:
shared folder and declare it in the extension module src/app/extensions/<name>/<name>.module.ts.ng g lazy-component extensions/<name>/shared/<component>/<component>.component.ts.@GenerateLazyComponent() to the component and registers ish-lazy-<component> in the exports module.shell.module for the header, and use ish-lazy-<component> in its template.Lazy components render only when the extension's feature toggle is enabled.
Therefore, the template that uses them needs no *ishFeature check for them.
Generated lazy components are git-ignored and recreated on npm install.
For example, see the QuickorderLinkComponent and its use as ish-lazy-quickorder-link in the header.
Because Angular Modules are a rather advanced topic, this section explains, based on the restructured project folder format, which modules exist and where components are declared.
The Angular modules are mainly used to feed the Angular dependency injection and with that component factories that populate the templates.
It has little to do with the bundling of lazy-loaded modules when a production-ready, ahead-of-time build is executed.
As a general rule of thumb, modules mainly aggregate deeper-lying artifacts.
Only a few exceptions are allowed.
As a developer who extends and customizes PWA functionality, consider modifying/adding to only the following modules:
src/app/pages/app.routing.module - for registering new globally available routessrc/app/core/core.module and configuration.module - for registering core functionality (if the third-party library documentation asks to add a SomeModule.forRoot(), this is the place)src/app/shell/shell.module - for declaring and exporting components that are available on the application shell and also on the remaining parts of the application; do not overuse this modulesrc/app/shared/shared.module - for declaring and exporting components that are used on more than one page, but not in the application shellsrc/app/pages/<name>/<name>-page.module - for declaring components that are used only on this pageAs a developer who develops new functionality for the PWA, you also work with the following modules:
src/app/core/X.module - configuration for the main application organized in various modulessrc/app/shared/<name>/<name>.module - utility modules that aggregate functionality exported with shared.modulesrc/app/core/store/**/<name>-store.module - ngrx-specific modules that you extend only when adding B2C functionality. Do not extend current stores; instead, add additional store modules for custom functionality.As a developer who adds new standalone features:
src/app/extensions/<name>/<name>.module - aggregated collection of components used for this extension, including the ngrx storesrc/app/extensions/<name>/exports/<name>-exports.module - aggregation of lazy components that lazily load the extension moduleWhen you use ng generate with the PWA custom schematics, it automatically declares the components in the correct modules.
The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Website, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.