gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ops-www] branch master updated: fix relative links


From: gnunet
Subject: [taler-taler-ops-www] branch master updated: fix relative links
Date: Sun, 25 Feb 2024 00:01:50 +0100

This is an automated email from the git hooks/post-receive script.

nora pushed a commit to branch master
in repository taler-ops-www.

The following commit(s) were added to refs/heads/master by this push:
     new 8e02c24  fix relative links
     new ce5ecca  Merge branch 'master' of git.taler.net:taler-ops-www
8e02c24 is described below

commit 8e02c24b0c3840929f0309ad30a1b490e72f1407
Author: Nullptrderef <nullptrderef@national.shitposting.agency>
AuthorDate: Sun Feb 25 00:01:31 2024 +0100

    fix relative links
---
 Makefile                   |  2 ++
 build-system/fix-paths.mjs | 27 +++++++++++++++++++++++++++
 package.json               |  7 ++++---
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 628d63f..8c8d3c9 100644
--- a/Makefile
+++ b/Makefile
@@ -25,8 +25,10 @@ prepare-parcel:
        ./build-system/pkgmgr run prepare-parcel;
 build-parcel:
        ./build-system/pkgmgr run build-parcel;
+       ./build-system/pkgmgr run fix-parcel-paths;
 build-parcel-no-optimize:
        ./build-system/pkgmgr run build-parcel-no-optimize;
+       ./build-system/pkgmgr run fix-parcel-paths;
 postbuild-parcel:
        ./build-system/pkgmgr run cleanup-parcel;
 
diff --git a/build-system/fix-paths.mjs b/build-system/fix-paths.mjs
new file mode 100644
index 0000000..d4b7109
--- /dev/null
+++ b/build-system/fix-paths.mjs
@@ -0,0 +1,27 @@
+import fs from 'fs';
+import path from 'path';
+
+const handleExtensions = ['css', 'js', 'html'];
+
+const distDir = path.resolve('dist');
+const distDirRead = fs
+  .readdirSync(distDir, {
+    recursive: true,
+  })
+  .map((v) => path.join(distDir, v));
+
+const applyTo = distDirRead.filter((file) =>
+  handleExtensions.find((ext) => file.toLowerCase().endsWith(ext)),
+);
+
+applyTo.forEach((targetFile) => {
+  fs.writeFileSync(
+    targetFile,
+    fs
+      .readFileSync(targetFile, 'utf-8')
+      .replace(
+        /BASE_URL/giu,
+        path.relative(path.join(targetFile, '..'), distDir),
+      ),
+  );
+});
diff --git a/package.json b/package.json
index 5c57f6d..92c4241 100644
--- a/package.json
+++ b/package.json
@@ -5,9 +5,10 @@
     "build-css": "sass rendered/scss:rendered/css",
     "optimize-css": "for file in rendered/css/*.css; do purifycss $file 
'rendered/**/*.html' -m -i -o $file.pure.css; mv $file.pure.css $file;done;",
     "prepare-parcel": "rm -f rendered/index.html && for file in 
rendered/**/*.html; do echo \"<a href='$file'>...</a>\" >> rendered/index.html; 
done; sed -i 's/rendered/./g' rendered/index.html",
-    "build-parcel": "parcel build rendered/index.html --public-url ./",
-    "build-parcel-no-optimize": "parcel build rendered/index.html --public-url 
./ --no-optimize",
-    "cleanup-parcel": "rm dist/index.html"
+    "build-parcel": "parcel build rendered/index.html --public-url BASE_URL",
+    "build-parcel-no-optimize": "parcel build rendered/index.html --public-url 
BASE_URL --no-optimize",
+    "cleanup-parcel": "rm dist/index.html",
+    "fix-parcel-paths": "node build-system/fix-paths.mjs"
   },
   "private": true,
   "devDependencies": {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]