Last active
November 17, 2022 12:15
-
-
Save polyrand/3bed83897658806bd490e1d44df4cd91 to your computer and use it in GitHub Desktop.
Revisions
-
polyrand revised this gist
Sep 14, 2022 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,6 @@ print("Downloading tailwindcss binary") # https://tailwindcss.com/blog/standalone-cli subprocess.run( [ "curl", -
polyrand revised this gist
Sep 14, 2022 . 1 changed file with 10 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,19 +10,20 @@ print("Downloading tailwindcss binary") # https://tailwindcss.com/blog/standalone-cli # chmod +x tailwindcss-macos-arm64 subprocess.run( [ "curl", "-SsL", "https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64", "-o", "tailwindcss", ], check=True, ) subprocess.run(["chmod", "+x", "tailwindcss"], check=True) if "alpine.js" not in os.listdir(): print("Downloading alpine.js") -
polyrand revised this gist
Sep 14, 2022 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,9 @@ if "alpine.js" not in os.listdir(): print("Downloading alpine.js") subprocess.run( ["curl", "-SsL", "https://unpkg.com/alpinejs", "-o", "alpine.js"], check=True ) tailwind_config = tempfile.NamedTemporaryFile() @@ -70,7 +72,8 @@ tailwind_config.name, "--output", "./output.css", ], check=True, ) tailwind_config.close() @@ -101,4 +104,4 @@ ) print("done") -
polyrand revised this gist
Sep 14, 2022 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ if "tailwindcss" not in os.listdir(): print("Downloading tailwindcss binary") # https://tailwindcss.com/blog/standalone-cli subprocess.run( """ @@ -24,6 +24,11 @@ ) if "alpine.js" not in os.listdir(): print("Downloading alpine.js") subprocess.run(["curl", "-SsL", "https://unpkg.com/alpinejs", "-o", "alpine.js"]) tailwind_config = tempfile.NamedTemporaryFile() tailwind_css = tempfile.NamedTemporaryFile() @@ -96,4 +101,4 @@ ) print("done") -
polyrand created this gist
Sep 14, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,99 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape from pathlib import Path import shutil import tempfile import subprocess import os if "tailwindcss" not in os.listdir(): print("downloading tailwind bin") # https://tailwindcss.com/blog/standalone-cli subprocess.run( """ set -euo pipefail curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64 chmod +x tailwindcss-macos-arm64 mv tailwindcss-macos-arm64 tailwindcss """.strip(), shell=True, check=True, ) tailwind_config = tempfile.NamedTemporaryFile() tailwind_css = tempfile.NamedTemporaryFile() tailwind_config.write( b""" module.exports = { content: ["./**/*.{html,js}"], theme: { extend: {}, }, plugins: [ require('@tailwindcss/typography'), require('@tailwindcss/forms'), require('@tailwindcss/aspect-ratio'), ] } """.strip() ) tailwind_config.flush() tailwind_css.write( b""" @tailwind base; @tailwind components; @tailwind utilities; """.strip() ) tailwind_css.flush() subprocess.run( [ "./tailwindcss", "--minify", "--input", tailwind_css.name, "--config", tailwind_config.name, "--output", "./output.css", ] ) tailwind_config.close() tailwind_css.close() loader = FileSystemLoader(".") t = Environment(loader=loader, autoescape=select_autoescape()) for file in Path.cwd().glob("*.html.j2"): rendered = t.get_template(file.name).render() with open(file.stem, "w") as f: f.write(rendered) with open(f"drop/{file.stem}", "w") as f: f.write(rendered) shutil.copyfile("./alpine.js", (Path.cwd() / "drop" / "alpine.js").resolve()) shutil.copyfile("./main.js", (Path.cwd() / "drop" / "main.js").resolve()) shutil.copyfile("./output.css", (Path.cwd() / "drop" / "output.css").resolve()) # Copy folder with static assets shutil.copytree( (Path.cwd() / "s").resolve(), (Path.cwd() / "drop" / "s").resolve(), dirs_exist_ok=True, ) print("done")