From 6db3a2ebc8712f01177d0ed3023222551865d8d9 Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Sun, 19 Mar 2023 12:51:32 +1000 Subject: [PATCH] Refactor how styles and scripts are built --- .zs/layout.html | 70 +++++++++++++++++++++++++++---------------------- .zs/posthook | 16 +++-------- .zs/scripts | 16 ++++++++++- .zs/styles | 14 ++++++++++ 4 files changed, 70 insertions(+), 46 deletions(-) create mode 100755 .zs/styles diff --git a/.zs/layout.html b/.zs/layout.html index 076dd82..fd0b17c 100644 --- a/.zs/layout.html +++ b/.zs/layout.html @@ -1,34 +1,40 @@ - - - - - - - - - {{ title }} - - - - - -
- -
-
{{ content }}
- - - {{ scripts }} - + + + + + {{ styles }} + + + + {{ title }} + + + + + + +
+ +
+
{{ content }}
+ + +{{ scripts }} + + \ No newline at end of file diff --git a/.zs/posthook b/.zs/posthook index c90ddc6..22c183d 100755 --- a/.zs/posthook +++ b/.zs/posthook @@ -1,24 +1,14 @@ #!/bin/sh -set -ex +set -e CSS="simple style" JS="live" for css in $CSS; do - if [ -f "$ZS_OUTDIR/css/$css.css" ]; then - minify -o "$ZS_OUTDIR/css/$css.min.css" "$ZS_OUTDIR/css/$css.css" - fi - if [ -f "$ZS_OUTDIR/css/$css.css" ]; then - rm "$ZS_OUTDIR/css/$css.css" - fi + minify -o "$ZS_OUTDIR/css/$css.min.css" "$ZS_OUTDIR/css/$css.css" done for js in $JS; do - if [ -f "$ZS_OUTDIR/js/$js.js" ]; then - minify -o "$ZS_OUTDIR/js/$js.min.js" "$ZS_OUTDIR/js/$js.js" - fi - if [ -f "$ZS_OUTDIR/js/$js.js" ]; then - rm "$ZS_OUTDIR/js/$js.js" - fi + minify -o "$ZS_OUTDIR/js/$js.min.js" "$ZS_OUTDIR/js/$js.js" done diff --git a/.zs/scripts b/.zs/scripts index d0a9dbc..d324fa8 100755 --- a/.zs/scripts +++ b/.zs/scripts @@ -1,5 +1,19 @@ #!/bin/sh +set -e + +JS="" + +# Load live.js for non-production builds for faster development if [ -z "$ZS_PRODUCTION" ]; then - echo '' + JS="$JS live" fi + +ext="js" +if [ -n "$ZS_PRODUCTION" ]; then + ext="min.js" +fi + +for js in $JS; do + printf "\n" "$js" "$ext" +done diff --git a/.zs/styles b/.zs/styles new file mode 100755 index 0000000..92a9bec --- /dev/null +++ b/.zs/styles @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +CSS="simple style" + +ext="css" +if [ -n "$ZS_PRODUCTION" ]; then + ext="min.css" +fi + +for css in $CSS; do + printf "\n" "$css" "$ext" +done