package res_tailwindcss
Install
Dune Dependency
Authors
Maintainers
Sources
md5=41ee181d9324e451341f5f99ba843ad1
sha512=c74b38da98efa381e0c950de0daa96f5c2702c770062733c6cbf2852b6737e5195aa6c7d56ab7775dbc4740a632e83814e0f987c5d747316752023b08484cfd7
Description
ppx_tailwindcss validates the tailwindcss class names in compile time.
Published: 31 Dec 2021
README
ReScript Tailwindcss
A ReScript PPX, which validates the tailwindcss class names
Motivation
The tailwind-ppx is the only ppx to validate the tailwindcss class names in compile time. But, it was archived, and written by ocaml-migrate-parsetree
. My team considered taking over the repository and maintaining it but decided to rewrite it from the scratch with ppxlib
and menhir
. Additionally, we improve the logic to find the invalid class name with Spelling Corrector algorithm.
Plus, the arbitrary values in the JIT mode of Tailwindcss is supported!
<!-- arbitrary value examples -->
<div className=%twc("p-[75px]")> ... </div>
<div className=%twc("p-[calc(75px)]")> ... </div>
<div className=%twc("bg-[#1da1f1]")> ... </div>
<div className=%twc("grid-cols-[1fr,700px,2fr]")> ... </div>
Install
yarn add -D @greenlabs/res-tailwindcss
<path_to_tailwindcss>
should be replaced with the relative location of your generated tailwindcss file from your project root in which the bsconfig.json
file is located.
// bsconfig.json
"ppx-flags": [
...,
["@greenlabs/res-tailwindcss/ppx", "--path <path_to_tailwindcss>"]
],
Example
<div className=%twc("flex justify-center items-center")>
...
</div>
Development
Create a sandbox with opam
// working directory : src
opam switch create tailwindcss 4.12.1
Install dependencies
// working directory : src
opam install . --deps-only --with-test
Build
// working directory : src
opam exec -- dune build
Test
cd test
(install dependencies)
yarn
(build --watch)
yarn res:clean && yarn res:watch
(run test --watch)
yarn test:watch
Dependencies (8)
-
menhir
>= "20211230"
- ppx_deriving
- ppx_expect
- ppx_inline_test
-
core
< "v0.15"
- ppxlib
-
dune
>= "2.8"
-
ocaml
>= "4.12.1"
Dev Dependencies
None
Used by
None
Conflicts
None