Coder Social home page Coder Social logo

tailwind's Introduction

Angular Tailwind CSS Schematics

This schematic will add Tailwind CSS to your Angular application.

Angular Tailwind CSS Schematics

Versions

@ngneat/tailwind AngularCLI
v6.x.x >= v11.1.x
v5.2.4 < v11.1.x

The main difference is Angular CLI v11.1+ uses PostCSS 8 already so we remove that from our dependencies list. To use this schematics at specific version, please use this syntax: ng add @ngneat/[email protected] or npm i -D @ngneat/[email protected]

Usage

ng add @ngneat/tailwind

Usage with Nx

In Nx, you can either use AngularCLI or NxCLI. If you setup your Nx Workspace to use AngularCLI, the usage is the same as above. If you setup your Nx Workspace with NxCLI, follow the steps:

Install @ngneat/tailwind first:

npm i -D @ngneat/tailwind
yarn add -D @ngneat/tailwind

then execute the schematics:

nx generate @ngneat/tailwind:nx-setup

Manual steps

If your projects are already using a custom Webpack builder with a custom webpack.config, follow these steps to add TailwindCSS to your project

  • npm i -D @ngneat/tailwind postcss (or yarn add -D @ngneat/tailwind postcss)
  • Import patchPostCSS from @ngneat/tailwind in your webpack.config
  • Import your TailwindCSS config in your webpack.config
  • Before you return or modify the original Webpack config, call patchPostCSS with the following parameters:
    • webpackConfig: the Webpack config
    • tailwindConfig: the TailwindCSS config that you import
    • components?: this flag will enable using TailwindCSS directives in components' stylesheets. Default to false because turning it on might impact your build time
// example
const { patchPostCSS } = require('@ngneat/tailwind');
const tailwindConfig = require('relative/path/to/tailwind.config');

module.exports = (config) => {
  patchPostCSS(config, tailwindConfig, true);
  return config;
}

Angular Material

If you plan to use @ngneat/tailwind with @angular/material, please make sure that you setup @angular/material before @ngneat/tailwind because @angular/material:ng-add schematics will error out if it detects a custom Webpack in your angular.json.

Purge

@ngneat/tailwind uses built-in purge functionality by tailwindcss (under the hood, it is postcss-purgecss). By default, @ngneat/tailwind sets the content to any HTML and any TS files in the project.

This behavior can be modified as the consumers see fit.

CSS Preprocessors

If you're using CSS Preprocessors (SASS/SCSS, LESS, Stylus) in your application, please check out TailwindCSS's Using with Preprocessors guide

Contributing

  • Fork this repo and clone the fork on your machine.
  • Run npm install to install all the dependencies
  • Start working on changes

Structure

_apps
 |__tailwind-e2e (e2e tests)
_libs
 |__tailwind
    |__src
       |__schematics
          |__ng-add (AngularCLI schematics)
          |__nx-setup (NxCLI schematics)
          |__files (files template to be generated)
          |__specs (unit tests)
          |__schema.d.ts (interface)
       |__constants (constants used in the project)
       |__utils (utilities functions)
       |__collection.json (schematics configuration)
       |__package.json (package.json of @ngneat/tailwind which will be published to npm)

Commit

  • Run git add . to stage your changes
  • Run npm run commit to start Conventional Commit flow

Commit Hooks

pre-commit will execute npm run lint and pretty-quick to lint and reformat.pre-commit does not run Unit Tests because Unit Tests will be ran in Github Actions. Feel free to run the Unit Tests with npm run test to test your changes

E2E Tests

Please run npm run e2e to run E2E tests before pushing

Updating README

README is in two places at the moment: root and libs/tailwind/README.md. The one in root is the one displayed on Github while the one in libs/tailwind is being used on npm. When you make changes to README, make sure to update both.

A script can be created to automating this.

PR

When everything passes and looks good, make a PR. Thanks for your contribution.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Chau Tran

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿ‘€

Netanel Basal

๐Ÿ’ป ๐Ÿค”

Santosh Yadav

๐Ÿค” ๐Ÿง‘โ€๐Ÿซ

BK

๐Ÿ’ป ๐Ÿค”

beeman

๐Ÿค” ๐Ÿง‘โ€๐Ÿซ ๐Ÿ’ป

Vlad Tansky

๐Ÿ’ป

Abhinav Dinesh C

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

tailwind's People

Contributors

nartc avatar vltansky avatar beeman avatar netanelbasal avatar bilal-io avatar abhinavdc avatar

Watchers

James Cloos 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.