Code Monkey home page Code Monkey logo

nx-angular-tailwind-starter's Introduction

NX Angular Tailwind Starter

Made with โค๏ธ ๐Ÿ˜… and ๐Ÿ˜น by Ady Ngom - @adyngom

Tailwind CSS is a superb utility first CSS framework that has taken the world of component first development by storm. It can be sometimes challenging to have it up and running in an Angular project let alone in an Nx workspace.

Though native support has been announced by the Angular team in upcoming versions, enterprise users who might want to take advantage of it might not have the luxury of quickly updating their versions.

Meet Tukki โœˆ๏ธ

Tukki means travel in my native tongue Wolof spoken in Senegal and the Gambia. It was a perfect name to give for a starter that will allow you to take a journey into Tailwind within an Angular project - first class with no frustations ๐Ÿ˜€โ›ฑ๏ธ

Quick Start & Documentation

You could just zip the project and check out the setup if you already have an existing project or you could just clone it and take it for a spin. If you choose the latter these steps might be helpful:

I assume you already have the Nx Cli installed, if not start with

npm install -g nx

you can swap yarn for npm if used as your package manager.

After cloning the repo cd into it and just run

npm install

you will see the structure below with tukki as the default app, a shared/ui folder under libs which host the bulk of the Tailwind UI components.

Tailwind was installed using the @ngneat/tailwind plugin - I highly recommend checking out the article - so you will see a couple of files that were added in root by the plugin: tailwind.config.js and webpack.config.js

In a short summary the plugin write an external webpack config file that properly adds the tailwind configuration, this gets picked by your build process using the @angular-builders/custom-webpack package.

You can see the modified entry in the **angular.json" file

"architect": {
        "build": {
          "builder": "@angular-builders/custom-webpack:browser",
          ...

You will also see that the Tailwind directives have been added as an import at the top of your styles.[s]css file

@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

You can read more about it in the article mentionned above, but now after having your dependencies installed, just run

npm start

When the build succeeds, you will notice a huge file size for your styles, which is to be expected since Tailwind comes with thousand of utility classes

But this is where postcss kicks in when you create a production build which gets rid off all the unwanted and unused CSS

Now you can navigate to your local url and you should see the page render just like the picture of the landing page above.

Now what??

Yeah you have an Angular project inside an Nx workspace with Tailwind properly setup - it's getting hot in here ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ

Take a look at the libs/shared/ui folder and see how I've tried to emulate the model from Angular material by having everything reusable as a module, you will find individuals components under the libs/shared/ui/partials folder and how everything gets imported in the app.module.ts file

/**
 * Shared modules
 */
import {
  SharedUiHeaderModule,
  SharedUiHeroModule,
  SharedUiPromoModule,
  SharedUiPartialsModule,
  SharedUiFooterModule,
} from '@tukki/shared/ui';

If you like that type of flow, well you are in for a treat, if not no hard feelings do what works for you - feel free to delete and replace as you see fit.

๐Ÿง™๐Ÿพ Tailwind's magic is sprinkled all around the project already and that's the only thing that matters

Copyrights notice and shoutouts

All the images use in the starter page are copyrighted to their respecvtive owners and should not be used in a commercial project without their consent or within the boundaries of their provided license agreements.

nx-angular-tailwind-starter's People

Contributors

adyngom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.