summaryrefslogtreecommitdiffstatshomepage
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Petros <apetros15@gmail.com>2023-12-21 12:18:46 -0500
committerAlexander Petros <apetros15@gmail.com>2023-12-21 12:20:48 -0500
commit7e484f65a4c76bc454bbe3c0975866cbf6ab4b2b (patch)
treea50772cabe8b270eee1f9e3280921d75a5d50027 /scripts
parent41e9ce3593ad921f7f5a43bd24048187444a1a58 (diff)
downloadhtmx-7e484f65a4c76bc454bbe3c0975866cbf6ab4b2b.tar.gz
htmx-7e484f65a4c76bc454bbe3c0975866cbf6ab4b2b.zip
Replace UMD with distribution script
This also includes a massive reformat of the htmx code, since the indenting was changed. I used standardJS for this.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dist.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/dist.sh b/scripts/dist.sh
new file mode 100755
index 00000000..20a31fa2
--- /dev/null
+++ b/scripts/dist.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# This script is intended to be run from npm, via `npm run dist`
+set -euo pipefail
+
+HTMX_SRC=src/htmx.js
+
+# Clean the dist directory
+rm -rf dist/*
+
+# Regular IIFE script
+cp $HTMX_SRC dist/
+
+# Minified script
+uglifyjs -m eval -o dist/htmx.min.js dist/htmx.js
+
+# Gzipped script
+gzip -9 -k -f dist/htmx.min.js > dist/htmx.min.js.gz
+
+# CJS script
+cat > dist/htmx.cjs.js << EOF
+$(cat $HTMX_SRC)
+module.exports = htmx;
+EOF
+
+# ESM script
+cat > dist/htmx.esm.js << EOF
+$(cat $HTMX_SRC)
+export { htmx }
+EOF