- Dan Wahlin
devpato
2 kinds
App Shared Code
Projects Shared Code
devpato
devpato
devpato
Where search-lib is the name of your library
ng generate library search-lib
devpato
NPM Enterprise Registry
devpato
devpato
PROS
devpato
CONS
devpato
Monorepos are a source control pattern where essentially all the codebase lives in the same repository. All projects will always use the latest version of the code.
What is a Monorepo?
devpato
PROS
devpato
devpato
npm install -g @nrwl/schematics
npx create-nx-workspace@latest thisdot
Install Nx globally
Create a Nx Workspace
devpato
Add the capability to create Angular applications via:
ng add @nrwl/angular --defaults
Now create your Angular app
ng g @nrwl/angular:application employees
devpato
Angular apps go here
Libraries used by your Angular apps go here
devpato
devpato
devpato
In your command line
ng g @nrwl/workspace:lib employee
Go to libs/data/src/lib/employee.ts
export interface Employee {
id: number;
name: string;
}
devpato
ng g @nrwl/angular:lib ui
devpato
ng g component employee-list --project=ui --export
devpato
export * from './lib/ui.module';
export * from './lib/employee.service';
devpato
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { EmployeeListComponent } from './employee-list/employee-list.component';
@NgModule({
imports: [CommonModule],
declarations: [EmployeeListComponent],
exports: [EmployeeListComponent]
})
export class UiModule {}
devpato
apps/employees/src/app/app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { UiModule } from '@thisdot/ui';
@NgModule({
declarations: [AppComponent],
imports: [
UiModule,
HttpClientModule,
BrowserModule,
RouterModule.forRoot([], { initialNavigation: 'enabled' })
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
devpato
<div class="employees-container">
<img src="../assets/images/logotdm.png" />
<h1>Employees</h1>
<thisdot-employee-list
[employees]="employeeService.employees$ | async">
</thisdot-employee-list>
</div>
devpato
devpato
"assets": [
"apps/employees/src/favicon.ico",
"apps/employees/src/assets",
{
"glob": "**/*",
"input": "./libs/ui/src/lib/shared-assets",
"output": "./assets"
}
]
devpato
devpato
devpato
tasks$: Observable<Task[]>;
tasks$: any;
tasks$: Observable<any[]>;
DO IT
DON'T IT
devpato
devpato
devpato
devpato
devpato
devpato
devpato
https://slides.com/patriciovargas/sass/fullscreen
devpato
devpato
@import '../../../shared/sass/variables';
.search-results-page {
width: 100%;
margin-top: 16px;
::ng-deep {
.ui-dataview {
width: 1000px;
height: 500px;
a {
&.ui-button {
&.ui-state-active {
background-color: $primary-green;
}
}
&.ui-paginator-page {
&.ui-state-active {
background-color: $primary-green;
}
}
}
&-content {
padding: 0;
}
}
}
}
devpato
devpato
devpato
devpato
-Angular Snippets
-Angular Console
-Angular Schematics
-Prettier
-Auto Rename Tag
-Highlight Matching Tag
-HTML Snippets
-IntelliSense for CSS class names in HTML
-JavaScript (ES6) code snippets
-RxJs Snippets
-Paste JSON as Code
devpato
Keep current with the latest Angular library releases
Don't modify your copy of Angular
Avoid Angular APIs marked in the documentation as “Security Risk.”
devpato
Angular Libraries with Nx for Enterprise Apps
https://tinyurl.com/wt2kmqb
devpato
Angular Development in Enterprise
https://tinyurl.com/w5nv8pz
Angular Architecture
https://tinyurl.com/ycheksoa