Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@shufo/tailwindcss-class-sorter

shufo81.1kMIT3.0.1TypeScript support: included

A tailwindcss class sorter that respects tailwind config file

tailwindcss

readme

npm CI codecov

tailwindcss-class-sorter

A tailwindcss class sorter that respects tailwind config file.

Installation

$ npm install @shufo/tailwindcss-class-sorter
# yarn
$ yarn add @shufo/tailwindcss-class-sorter

Usage

// CommonJS
const { sortClasses } = require("@shufo/tailwindcss-class-sorter");

const sorted = sortClasses("pt-2 p-4");
console.log(sorted);
// => "p-4 pt-2"

// ESModule
import { sortClasses } from "tailwindcss-class-sorter";
const sorted = sortClasses("pt-2 p-4");

tailwindcss-class-sorter will automatically look for tailwind.config.js in the project directory. Then if it exists, it will sort according to the tailwindcss configuration. If it does not exist, the default sort order of tailwindcss plugin will be used.

API

functions

sortClasses(classes: string, options: IOption)

classes: classes string e.g. z-5 z-50

Interfaces

IOption

export interface IOption {
  tailwindConfigPath?: string;
  tailwindConfig?: TailwindConfig;
}
key value
tailwindConfigPath A path to tailwind config file
tailwindConfig A configuration object of tailwind config

Testing

$ yarn install
$ yarn run test

Benchmarking

$ yarn run benchmark

image

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

LICENSE

MIT

changelog

Changelog

3.0.1 (2023-07-06)

Fixes

  • 🐛 use loadConfig for module loading (439bad9)

Miscellaneous

  • 🤖 remove synckit from dependencies (33f7934)

3.0.0 (2023-07-01)

Features

Miscellaneous

  • deps: update dependency @types/jest to v29 (bb65dc9)
  • deps: update dependency husky to v8 (8d849c3)
  • deps: update dependency lint-staged to v13 (4dfa1c6)
  • deps: update dependency typescript to v5 (d7d2c69)
  • release 3.0.0 (3d89927)

2.0.0 (2023-01-20)

⚠ BREAKING CHANGES

  • 🧨 drop support for node 12.x

Features

  • 🎸 support tailwind 3.2 (8c08b53)

Miscellaneous

  • 🤖 bump tailwindcss to 3.2.4 (2080eaf)
  • 🤖 drop support for node 12.x (97b45ee)
  • deps: update pozil/auto-assign-issue action to v1.11.0 (b156b17)

1.0.12 (2022-09-21)

Fixes

  • 🐛 create context based on config hash (a1c5084)

1.0.11 (2022-09-20)

Fixes

  • 🐛 uncached default sorting is affecting performance (e8d2fd4)

1.0.10 (2022-09-19)

Fixes

  • 🐛 slow performance with uncached tailwind config object (6dd6f61)

1.0.9 (2022-09-19)

Fixes

  • 🐛 tailwindConfig caches context unexpectedly (ffd98c9)

Miscellaneous

  • 💡 delete unnecessary console.log (9cb1aeb)

1.0.8 (2022-09-18)

Miscellaneous

  • 💡 improve error message for config file (0f3de1d)
  • deps: bump minimist from 1.2.5 to 1.2.6 (6295e69)

1.0.7 (2022-09-17)

Fixes

  • 🐛 import config type from tailwindcss (2858a4a)

Miscellaneous

  • 🤖 bump tailwindcss to 3.1.8 (521f91e)
  • 🤖 delete @types/tailwindcss from dependencies (192473f)

1.0.6 (2022-09-17)

Fixes

  • 🐛 import type from tailwindcss/defaultConfig (e27375f)

Miscellaneous

  • 💡 improve message for config not found error (c66b6fc)
  • 🤖 add refactor type to change log types (9683647)
  • 🤖 disable pinning (4e59016)
  • 🤖 revert @types/tailwindcss to 3.0.9 (72f1dc4)
  • 🤖 update renovate.json config (b4ae20d)

1.0.5 (2022-09-17)

Miscellaneous

  • deps: add renovate.json (153c992)
  • deps: update actions/cache action to v3 (05a1992)
  • deps: update actions/checkout action to v3 (91b816f)
  • deps: update actions/setup-node action to v3 (7e253d9)
  • deps: update akhilmhdh/contributors-readme-action action to v2.3.6 (e6f24ef)
  • deps: update codecov/codecov-action action to v3 (50014a0)
  • deps: update dependency @tailwindcss/typography to v0.5.7 (c4b8ee0)
  • deps: update dependency @types/tailwindcss to v3.0.11 (363be77)
  • deps: update dependency esbuild to v0.15.7 (407456b)
  • deps: update dependency eslint to v8.23.1 (bab24ac)
  • deps: update dependency prettier to v2.7.1 (0a45d44)
  • deps: update dependency prettier-plugin-tailwindcss to v0.1.13 (9746058)
  • deps: update googlecloudplatform/release-please-action action to v3 (d119584)
  • deps: update pozil/auto-assign-issue action to v1.10.0 (a4b223f)

1.0.4 (2022-05-11)

Miscellaneous

  • 🤖 (deps-dev) add codecov (c57d40d)
  • deps: bump tailwindcss from 3.0.23 to 3.0.24 (218ffbb)

1.0.3 (2022-02-26)

Fixes

  • 🐛 avoid optionial chain syntax to support node 12.x (cba197b)

Miscellaneous

  • 🤖 support node12.x for backward compatibility (2603089)

1.0.2 (2022-02-25)

Miscellaneous

  • 🤖 (dev-deps) add benny to dev dependencies (e218645)
  • 🤖 add ignore pattern for benchmark (19aa712)
  • 🤖 add object-hash to dependencies (6353bf4)

Performance

  • ⚡️ add benchmark script to measure performance (2d4b1e6)
  • ⚡️ improve creating context performance by cache context (16e5d96)

1.0.1 (2022-02-25)

Miscellaneous

  • 🤖 (dev-deps) delete unnecessary package (22aa384)

1.0.0 (2022-02-25)

Miscellaneous