Skip to content

Commit

Permalink
Survive tailwindcss binary (#2773)
Browse files Browse the repository at this point in the history
* Survive tailwindcss binary

* When building target specific binary
  - If already available in installed world, copy
  - If not found, download
  - Using %{bin-available} does not work, targets are always available

* Define a package tailwindcss which allows installing tailwindcss in
local switch

* Making tailwindcss survive dune clean:
  - dune build tailwindcss.install
  - dune install -p tailwindcss
  - This does not work if written in dune file. Everything takes place
    indide _build

Note: While debugging, doing progn / chmod / copy in tailwindcss rules
made curl happen take place twice.

* Add HACKING note

---------

Co-authored-by: Cuihtlauac ALVARADO <[email protected]>
  • Loading branch information
cuihtlauac and Cuihtlauac ALVARADO authored Jan 27, 2025
1 parent e47377e commit 5526793
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
4 changes: 4 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ was upgraded in the process, the files `.ocamlformat` and
`.github/workflows/ci.yml` must be modified with the currently installed version
of OCamlFormat.

### Handling the Tailwind CSS

The Tailwind CSS framework. The tailwind binary pulled from its GitHub [repo](https://github.com/tailwindlabs/tailwindcss). Download is performed by Dune during the build. When working on a local switch for hacking, you don't want `dune clean` to delete this binary. Just do `dune install tailwind` to have it installed in the local switch.

## Repository Structure

The following snippet describes the repository structure:
Expand Down
11 changes: 1 addition & 10 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
(rule
(target main.css)
(deps
%{project_root}/tool/tailwind/tailwindcss
(:config %{project_root}/tailwind.config.js)
(:input %{project_root}/src/ocamlorg_frontend/css/styles.css)
(source_tree %{project_root}/src/ocamlorg_frontend))
(action
(chdir
%{project_root}
(run
%{project_root}/tool/tailwind/tailwindcss
-m
-c
%{config}
-i
%{input}
-o
%{target})))))
(run tailwindcss -m -c %{config} -i %{input} -o %{target})))))

(subdir
asset/
Expand Down
3 changes: 3 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

(using mdx 0.1)

(package
(name tailwindcss) (allow_empty))

(package
(name ocamlorg)
(synopsis "Official OCaml website")
Expand Down
37 changes: 21 additions & 16 deletions tool/tailwind/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@
(target tailwindcss-linux-x64)
(action
(progn
(run
curl
-sLO
https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target})
(with-stdout-to
%{target}
(bash
"cat 2> /dev/null < $(which tailwindcss) || curl -#fSL https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target}"))
(run chmod +x %{target}))))

(rule
(target tailwindcss-linux-arm64)
(action
(progn
(run
curl
-sLO
https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target})
(with-stdout-to
%{target}
(bash
"cat 2> /dev/null < $(which tailwindcss) || curl -#fSL https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target}"))
(run chmod +x %{target}))))

(rule
(target tailwindcss-macos-x64)
(action
(progn
(run
curl
-sLO
https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target})
(with-stdout-to
%{target}
(bash
"cat 2> /dev/null < $(which tailwindcss) || curl -#fSL https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target}"))
(run chmod +x %{target}))))

(rule
(target tailwindcss-macos-arm64)
(action
(progn
(run
curl
-sLO
https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target})
(with-stdout-to
%{target}
(bash
"cat 2> /dev/null < $(which tailwindcss) || curl -#fSL https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target}"))
(run chmod +x %{target}))))

(rule
Expand Down Expand Up @@ -81,3 +81,8 @@
(alias
(name default)
(deps tailwindcss))

(install
(section bin)
(package tailwindcss)
(files tailwindcss))

0 comments on commit 5526793

Please sign in to comment.