DEV Community

Cover image for Así puedes abreviar los imports en angular
Danniel Navas
Danniel Navas

Posted on • Edited on

1

Así puedes abreviar los imports en angular

En muchas ocasiones importando nuestros módulos o diferentes funcionalidades custom quedamos con rutas como estas:



import { Youtube } from '../../../core/models/youtube/youtube';


Enter fullscreen mode Exit fullscreen mode

lo que nos ocasiona un desagrado visual y a futuro algo poco mantenible.

Para esto utilizaremos lo denominado short links y mejoraremos la visual de nuestras importaciones, solo necesitaremos nuestro file tsconfig.json el cual se encuentra en la raíz de nuestro proyecto.

Sobre este empezaremos agregando el atributo paths dentro de compilerOptions, en este crearemos un objeto json que contendrá todas las rutas a las cuales queremos acortar la importación, como resultado tendremos algo parecido a esto:

Alt Text

Configurado la próxima vez que importemos será algo parecido a:



import { Youtube } from '@core/models/youtube/youtube';


Enter fullscreen mode Exit fullscreen mode

Espero te ayudara con una mejora sobre tus proyectos actuales y próximos.

Gracias por leer.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay