From 9bfc8173684914d0ab1ee051a58913f831745c44 Mon Sep 17 00:00:00 2001 From: Yureka Date: Wed, 27 Dec 2023 12:48:20 +0100 Subject: [PATCH] frontend: template version and revision --- flake.nix | 7 +++++-- frontend/webpack.config.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 2cb9629..80ebd8e 100644 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,7 @@ fernglas-frontend = final.callPackage ( { lib, stdenv, yarn2nix-moretea, yarn, nodejs-slim }: - stdenv.mkDerivation { + stdenv.mkDerivation (finalDrv: { pname = "fernglas-frontend"; version = self.shortRev or "dirty-${toString self.lastModifiedDate}"; @@ -60,6 +60,9 @@ }; }; + env.FERNGLAS_COMMIT = self.rev or "main"; + env.FERNGLAS_VERSION = finalDrv.version; + offlineCache = let yarnLock = ./frontend/yarn.lock; yarnNix = yarn2nix-moretea.mkYarnNix { inherit yarnLock; }; @@ -91,7 +94,7 @@ mv dist $out runHook postInstall ''; - } + }) ) { }; diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index f6143f0..fdc381e 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -22,7 +22,17 @@ module.exports = { }, plugins: [ new CopyPlugin({ - patterns: [ "static" ] + patterns: [ + { + from: "static", + transform: (content) => { + return content + .toString() + .replace('#VERSION#', process.env.FERNGLAS_VERSION) + .replace('#COMMIT#', process.env.FERNGLAS_COMMIT); + }, + } + ] }) ] };