Skip to content

Commit

Permalink
Merge pull request #71 from compolabs/feat/log-version
Browse files Browse the repository at this point in the history
Add version in the build
  • Loading branch information
EchoDex authored Feb 22, 2024
2 parents b83828f + fe73ffd commit 105cc7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spark-frontend/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spark-frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
// <React.StrictMode>
Expand Down
2 changes: 2 additions & 0 deletions spark-frontend/src/typings/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ declare module "*.module.sass" {
const classes: { readonly [key: string]: string };
export default classes;
}

declare const __COMMIT_HASH__: string;

0 comments on commit 105cc7b

Please sign in to comment.