From fe73ffda961bbe2e1b6bb27766dfda343c7604f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B8b=C4=97rt=C3=B8?= <106074508+EchoDex@users.noreply.github.com> Date: Thu, 22 Feb 2024 13:55:20 +0400 Subject: [PATCH] feat: add version in the build --- spark-frontend/config/webpack.config.js | 10 ++++++++++ spark-frontend/src/index.tsx | 2 ++ spark-frontend/src/typings/react-app-env.d.ts | 2 ++ 3 files changed, 14 insertions(+) diff --git a/spark-frontend/config/webpack.config.js b/spark-frontend/config/webpack.config.js index 3f2a9c61..961c21ae 100644 --- a/spark-frontend/config/webpack.config.js +++ b/spark-frontend/config/webpack.config.js @@ -85,6 +85,13 @@ const hasJsxRuntime = (() => { } })(); +const COMMIT_HASH = require('child_process') +.execSync('git rev-parse --short HEAD') +.toString() +.trim(); + +console.log(COMMIT_HASH) + // This is the production and development configuration. // It is focused on developer experience, fast rebuilds, and a minimal bundle. module.exports = function (webpackEnv) { @@ -751,6 +758,9 @@ module.exports = function (webpackEnv) { }, }, }), + new webpack.DefinePlugin({ + __COMMIT_HASH__: JSON.stringify(COMMIT_HASH) + }) ].filter(Boolean), // Turn off performance processing because we utilize // our own hints via the FileSizeReporter diff --git a/spark-frontend/src/index.tsx b/spark-frontend/src/index.tsx index 682cc831..53ab8fe1 100644 --- a/spark-frontend/src/index.tsx +++ b/spark-frontend/src/index.tsx @@ -19,6 +19,8 @@ const initState = loadState(); const STORE = RootStore.create(initState); +console.warn(`Version: ${__COMMIT_HASH__}`); + const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement); root.render( // diff --git a/spark-frontend/src/typings/react-app-env.d.ts b/spark-frontend/src/typings/react-app-env.d.ts index 3523af0c..885ba0d4 100644 --- a/spark-frontend/src/typings/react-app-env.d.ts +++ b/spark-frontend/src/typings/react-app-env.d.ts @@ -80,3 +80,5 @@ declare module "*.module.sass" { const classes: { readonly [key: string]: string }; export default classes; } + +declare const __COMMIT_HASH__: string; \ No newline at end of file