Skip to content

Commit 5526793

Browse files
cuihtlauacCuihtlauac ALVARADO
and
Cuihtlauac ALVARADO
authored
Survive tailwindcss binary (#2773)
* 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]>
1 parent e47377e commit 5526793

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

HACKING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ was upgraded in the process, the files `.ocamlformat` and
147147
`.github/workflows/ci.yml` must be modified with the currently installed version
148148
of OCamlFormat.
149149

150+
### Handling the Tailwind CSS
151+
152+
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.
153+
150154
## Repository Structure
151155

152156
The following snippet describes the repository structure:

dune

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@
33
(rule
44
(target main.css)
55
(deps
6-
%{project_root}/tool/tailwind/tailwindcss
76
(:config %{project_root}/tailwind.config.js)
87
(:input %{project_root}/src/ocamlorg_frontend/css/styles.css)
98
(source_tree %{project_root}/src/ocamlorg_frontend))
109
(action
1110
(chdir
1211
%{project_root}
13-
(run
14-
%{project_root}/tool/tailwind/tailwindcss
15-
-m
16-
-c
17-
%{config}
18-
-i
19-
%{input}
20-
-o
21-
%{target})))))
12+
(run tailwindcss -m -c %{config} -i %{input} -o %{target})))))
2213

2314
(subdir
2415
asset/

dune-project

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
(using mdx 0.1)
2626

27+
(package
28+
(name tailwindcss) (allow_empty))
29+
2730
(package
2831
(name ocamlorg)
2932
(synopsis "Official OCaml website")

tool/tailwind/dune

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@
22
(target tailwindcss-linux-x64)
33
(action
44
(progn
5-
(run
6-
curl
7-
-sLO
8-
https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target})
5+
(with-stdout-to
6+
%{target}
7+
(bash
8+
"cat 2> /dev/null < $(which tailwindcss) || curl -#fSL https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.6/%{target}"))
99
(run chmod +x %{target}))))
1010

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

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

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

4141
(rule
@@ -81,3 +81,8 @@
8181
(alias
8282
(name default)
8383
(deps tailwindcss))
84+
85+
(install
86+
(section bin)
87+
(package tailwindcss)
88+
(files tailwindcss))

0 commit comments

Comments
 (0)