In this article, I am going to start with very basic Angular schematic implementation and slowly build the code for this complete angular-tailwindcss-schematics project. At each milestone, I will share the git commit link to check the code and files at that stage and also explaining the step.

Recently, I thought of giving tailwindcss a try (after hearing and reading so much about this utility-first CSS framework). My plan was to use tailwindcss with  Angular. So I started looking for documents on how to integrate tailwindcss with Angular and found couple of good articles.

Going through these document, you will soon understand that integrating tailwindcss to Angular is not that straightforward (as in executing a single command) but involves a series of steps.

Luckily I also found this library that makes the integration really simple (yes, executing a single command!). This library uses  Angular schematics to automate this process.

Now just to understand better, first I followed the manual process and then also tried the schematics library (@ngneat/tailwind) to integrate tailwindcss to Angular. My primary goal was completed.

However, few months back, I had started learning about Schematics in Angular and like many other learning and side projects, I had abandoned it in favor of something else (do not remember exactly what for). I thought of resuming it back and this time not only learn the concepts but actually create a useful (but simple) Angular schematic.

As mentioned before in this article, I will not be going into explaining concepts related to Angular Schematics. Please refer  this and  this for detailed explanation. Going through these articles and reading more about Schematics, I would say and the main files that we will work with are:

  • collection.json - schematic definition file.
  • index.ts - Schematic factory function file.
  • schema.json - Contains options to be passed to the factory function.
  • schema.ts - Contains interface for the schematic options
  • files - Directory that contains template file to be created.

#angular #tailwindcss #css

Implementing Angular Schematics using Angular + Tailwind CSS example.
9.20 GEEK