Skip to content

Commit

Permalink
frontend: template version and revision
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyuyureka committed Dec 27, 2023
1 parent 6be72bf commit 9bfc817
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 5 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand All @@ -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; };
Expand Down Expand Up @@ -91,7 +94,7 @@
mv dist $out
runHook postInstall
'';
}
})

) { };

Expand Down
12 changes: 11 additions & 1 deletion frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
}
]
})
]
};
Expand Down

0 comments on commit 9bfc817

Please sign in to comment.