-Codigo compartido por app
-Codigo compartido en proyectos con librerías
Lo bueno
Lo malo
Monorepos es una forma de construir aplicaciones donde todo tu código vive bajo el mismo repositorio. Todos tus proyectos van a utilizar las misma version de código.
Qué es un Monorepo?
lo bueno
En tu linea de comando
nx g @nrwl/workspace:lib post
Ve a libs/post/src/lib/post.ts
export interface Post {
id: string;
title: string;
author: string;
description: string;
imageUrl: string;
}
nx g @nrwl/angular:lib ui
nx g component posts --project=ui --export
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PostsComponent } from './posts/posts.component';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [CommonModule, RouterModule],
declarations: [PostsComponent],
exports: [PostsComponent],
})
export class UiModule {}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { PostDetailsComponent } from './post-details/post-details.component';
import { PostsPageComponent } from './posts-page/posts-page.component';
/**
* UI Lib Module
*/
import { UiModule } from '@ngconf/ui';
@NgModule({
declarations: [AppComponent, PostDetailsComponent, PostsPageComponent],
imports: [BrowserModule, AppRoutingModule, HttpClientModule, UiModule ],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
<div class="content" *ngIf="posts$ | async as posts">
<ngconf-posts [posts]="posts"></ngconf-posts>
</div>
nx g s blog --project=ui
export * from './lib/ui.module';
export * from './lib/blog.service';
"assets": [
"apps/blog/src/favicon.ico",
"apps/blog/src/assets",
{
"glob": "**/*",
"input": "./libs/shared-assets",
"output": "./assets"
}
],
<img src="../assets/images/ngconfco.png" />
AngularHispana
devpato
https://tinyurl.com/wt2kmqb
https://tinyurl.com/w5nv8pz