diff --git a/.eslintrc.json b/.eslintrc.json index c9940fe..9864689 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,7 +17,8 @@ "globals": { "pageContent": "writable", "module": "writable", - "process": "writable" + "process": "writable", + "__COMMIT_HASH__": "writable" }, "rules": { "no-unused-vars": [ diff --git a/src/main.ts b/src/main.ts index 468d33d..c9abf49 100644 --- a/src/main.ts +++ b/src/main.ts @@ -126,6 +126,8 @@ async function onLoad() { } document.addEventListener('DOMContentLoaded', async function () { + // @ts-expect-error + console.log("Loading Version:", __COMMIT_HASH__); i18next.init({ lng: pageState.language, fallbackLng: 'en', diff --git a/webpack.config.js b/webpack.config.js index 493e575..201b72c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,6 @@ const path = require('path'); +const webpack = require('webpack'); + const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); @@ -6,6 +8,9 @@ const VERBOSE = Object.getOwnPropertyNames(process.env).includes("VERBOSE") || ! const MODE = process.env.WEBPACK_MODE || "production" const DEBUG = MODE != "production"; +let commitHash = require('child_process') + .execSync('git rev-parse --short HEAD') + .toString(); module.exports = { mode: MODE, @@ -20,7 +25,13 @@ module.exports = { colors: true, timings: true, }, - plugins: [new MiniCssExtractPlugin(), new HtmlWebpackPlugin({ title: "VaultUI" })], + plugins: [ + new MiniCssExtractPlugin(), + new HtmlWebpackPlugin({ title: "VaultUI" }), + new webpack.DefinePlugin({ + __COMMIT_HASH__: JSON.stringify(commitHash), + }) + ], devServer: { open: process.env.BROWSER || "microsoft-edge-dev", },