Refactor how styles and scripts are built

This commit is contained in:
James Mills 2023-03-19 12:51:32 +10:00
parent b9cb02d2d6
commit 6db3a2ebc8
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
4 changed files with 70 additions and 46 deletions

View File

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/css/simple.min.css">
<link rel="stylesheet" href="/css/style.min.css">
{{ styles }}
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
@ -12,13 +12,18 @@
<meta name="title" content="{{ title }}" />
<meta name="description" content="{{ description }}" />
<meta name="keywords" content="{{ keywords }}" />
</head>
<body>
</head>
<body>
<header>
<nav>
<a href="/">Home</a></li>
<a href="https://zs.mills.io/">Demo</a></li>
<a href="https://git.mills.io/prologic/zs-starter-template"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M5.583 7.229C3.119 7.224-.172 8.786.01 12.708c.281 6.125 6.557 6.693 9.068 6.745c.271 1.146 3.224 5.109 5.411 5.318h9.573c5.74-.38 10.036-17.365 6.854-17.427c-5.271.25-8.396.375-11.073.396v5.297l-.839-.365l-.005-4.932c-3.073 0-5.781-.141-10.917-.396c-.646-.005-1.542-.115-2.5-.115zm.344 2.167h.297c.349 3.141.917 4.974 2.068 7.781c-2.938-.349-5.432-1.198-5.891-4.38c-.24-1.646.563-3.365 3.526-3.401zm11.412 3.083c.198.005.406.042.594.13l1 .432l-.714 1.302a.989.989 0 0 0-.323.052c-.464.151-.708.604-.542 1.021a.843.843 0 0 0 .151.229l-1.234 2.25a.841.841 0 0 0-.297.052c-.464.146-.708.604-.542 1.016c.172.417.682.63 1.151.479c.464-.146.703-.604.536-1.021a.834.834 0 0 0-.208-.292l1.203-2.188c.13.01.26 0 .391-.042a.805.805 0 0 0 .281-.151c.464.198.844.354 1.12.49c.406.203.552.339.599.49c.042.146-.005.427-.24.922c-.172.37-.458.896-.797 1.51c-.115 0-.229.016-.333.052c-.469.151-.708.604-.542 1.021c.167.411.682.625 1.146.479c.469-.151.708-.604.542-1.021a.862.862 0 0 0-.182-.271c.333-.609.62-1.135.807-1.526c.25-.536.38-.938.266-1.323s-.469-.635-.932-.865c-.307-.151-.693-.313-1.146-.505c.005-.109-.01-.214-.052-.318s-.109-.198-.193-.281l.703-1.281l3.901 1.682c.703.307.995 1.057.651 1.682l-2.682 4.906c-.339.625-1.182.885-1.885.578l-5.516-2.38c-.703-.307-.995-1.057-.656-1.682l2.682-4.906c.234-.432.708-.688 1.208-.708h.083z"/></svg>Source</a>
<a href="https://git.mills.io/prologic/zs-starter-template"><svg xmlns="http://www.w3.org/2000/svg" class="icon"
width="32" height="32" viewBox="0 0 32 32">
<path fill="currentColor"
d="M5.583 7.229C3.119 7.224-.172 8.786.01 12.708c.281 6.125 6.557 6.693 9.068 6.745c.271 1.146 3.224 5.109 5.411 5.318h9.573c5.74-.38 10.036-17.365 6.854-17.427c-5.271.25-8.396.375-11.073.396v5.297l-.839-.365l-.005-4.932c-3.073 0-5.781-.141-10.917-.396c-.646-.005-1.542-.115-2.5-.115zm.344 2.167h.297c.349 3.141.917 4.974 2.068 7.781c-2.938-.349-5.432-1.198-5.891-4.38c-.24-1.646.563-3.365 3.526-3.401zm11.412 3.083c.198.005.406.042.594.13l1 .432l-.714 1.302a.989.989 0 0 0-.323.052c-.464.151-.708.604-.542 1.021a.843.843 0 0 0 .151.229l-1.234 2.25a.841.841 0 0 0-.297.052c-.464.146-.708.604-.542 1.016c.172.417.682.63 1.151.479c.464-.146.703-.604.536-1.021a.834.834 0 0 0-.208-.292l1.203-2.188c.13.01.26 0 .391-.042a.805.805 0 0 0 .281-.151c.464.198.844.354 1.12.49c.406.203.552.339.599.49c.042.146-.005.427-.24.922c-.172.37-.458.896-.797 1.51c-.115 0-.229.016-.333.052c-.469.151-.708.604-.542 1.021c.167.411.682.625 1.146.479c.469-.151.708-.604.542-1.021a.862.862 0 0 0-.182-.271c.333-.609.62-1.135.807-1.526c.25-.536.38-.938.266-1.323s-.469-.635-.932-.865c-.307-.151-.693-.313-1.146-.505c.005-.109-.01-.214-.052-.318s-.109-.198-.193-.281l.703-1.281l3.901 1.682c.703.307.995 1.057.651 1.682l-2.682 4.906c-.339.625-1.182.885-1.885.578l-5.516-2.38c-.703-.307-.995-1.057-.656-1.682l2.682-4.906c.234-.432.708-.688 1.208-.708h.083z" />
</svg>Source</a>
</nav>
</header>
<main>{{ content }}</main>
@ -29,6 +34,7 @@
Built with <a href="https://git.mills.io/prologic/zs">zs
</p>
</footer>
</body>
{{ scripts }}
</body>
{{ scripts }}
</html>

View File

@ -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
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
done

View File

@ -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 '<script type="application/javascript" src="/js/live.min.js"></script>'
JS="$JS live"
fi
ext="js"
if [ -n "$ZS_PRODUCTION" ]; then
ext="min.js"
fi
for js in $JS; do
printf "<script type=\"application/javascript\" src=\"/js/%s.%s\"></script>\n" "$js" "$ext"
done

14
.zs/styles Executable file
View File

@ -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 "<link rel=\"stylesheet\" href=\"/css/%s.%s\">\n" "$css" "$ext"
done