summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile2
-rw-r--r--docker-entrypoint.sh6
-rw-r--r--esbuild.config.js1
-rw-r--r--src/index.html3
-rw-r--r--src/ts/script.ts14
5 files changed, 14 insertions, 12 deletions
diff --git a/Dockerfile b/Dockerfile
index 26c8c2a..a7f4197 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,8 +10,6 @@ RUN npm run build
FROM nginx:alpine as adelie
-ENV HOST=https://adelie.liz.coffee
-
COPY --from=builder /app/dist/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
COPY docker-entrypoint.sh /docker-entrypoint.sh
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index c2facc7..3ea754c 100644
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -1,9 +1,3 @@
#!/bin/sh
-if [ -n "$HOST" ]; then
- sed -i "s|ASSET_BASE_PLACEHOLDER|$HOST|g" /usr/share/nginx/html/index.html
-else
- sed -i 's|"ASSET_BASE_PLACEHOLDER"|""|g' /usr/share/nginx/html/index.html
-fi
-
exec nginx -g 'daemon off;'
diff --git a/esbuild.config.js b/esbuild.config.js
index 1a7e09b..cb83e51 100644
--- a/esbuild.config.js
+++ b/esbuild.config.js
@@ -38,7 +38,6 @@ async function copyAssets() {
async function processHTML() {
let html = await fs.readFile('src/index.html', 'utf8');
- html = html.replace(/ASSET_BASE_PLACEHOLDER/g, '');
await fs.writeFile('dist/index.html', html);
}
diff --git a/src/index.html b/src/index.html
index b20e703..835f76d 100644
--- a/src/index.html
+++ b/src/index.html
@@ -4,9 +4,6 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Liz CSS - Framework Demo</title>
- <script>
- window.ASSET_BASE = 'ASSET_BASE_PLACEHOLDER';
- </script>
<link rel="stylesheet" href="/bundle.css" />
<link rel="icon" href="/img/favicon.ico" />
<style>
diff --git a/src/ts/script.ts b/src/ts/script.ts
index e0b0b85..56c6d63 100644
--- a/src/ts/script.ts
+++ b/src/ts/script.ts
@@ -4,6 +4,20 @@ import 'prismjs/components/prism-css';
import 'prismjs/components/prism-markup';
import { initOneko } from './oneko';
+// Auto-detect asset base from the bundled script's origin
+(() => {
+ window.ASSET_BASE = '';
+ const bundleScript = document.querySelector('script[src*="bundle"]');
+ if (bundleScript?.src) {
+ try {
+ const url = new URL(bundleScript.src, window.location.href);
+ window.ASSET_BASE = url.origin;
+ } catch {
+ // Fall back to empty string
+ }
+ }
+})();
+
(() => {
const toggleButton = document.getElementById('theme-toggle') as HTMLInputElement;
const html = document.documentElement;