A tailwindcss class sorter that respects tailwind config file
npm install @shufo/tailwindcss-class-sorter


A tailwindcss class sorter that respects tailwind config file.
``bash`
$ npm install @shufo/tailwindcss-class-sorteryarn
$ yarn add @shufo/tailwindcss-class-sorter
`typescript
// 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.
#### sortClasses(classes: string, options: IOption)
classes: classes string e.g. z-5 z-50
#### IOption
`typescript`
export interface IOption {
tailwindConfigPath?: string;
tailwindConfig?: TailwindConfig;
}
| key | value |
| ------------------ | ----------------------------------------- |
| tailwindConfigPath | A path to tailwind config file |
| tailwindConfig | A configuration object of tailwind config |
`bash`
$ yarn install
$ yarn run test
`bash`
$ yarn run benchmark
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)git commit -am 'Add some feature'
3. Commit your changes ()git push origin my-new-feature`)
4. Push to the branch (
5. Create new Pull Request
MIT