diff --git a/.eslintrc.json b/.eslintrc.json index 9864689..982669f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,7 +18,7 @@ "pageContent": "writable", "module": "writable", "process": "writable", - "__COMMIT_HASH__": "writable" + "BUILD_STRING": "writable" }, "rules": { "no-unused-vars": [ diff --git a/package.json b/package.json index e88d9ea..ecebcdb 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "eslint-plugin-import": "^2.22.1", "eslint-plugin-sort-imports-es6-autofix": "^0.6.0", "file-saver": "^2.0.5", + "git-revision-webpack-plugin": "^5.0.0", "html-webpack-plugin": "^5.3.1", "i18next": "^20.2.1", "mini-css-extract-plugin": "^1.4.1", diff --git a/src/main.ts b/src/main.ts index c9abf49..7d0957b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -126,8 +126,9 @@ async function onLoad() { } document.addEventListener('DOMContentLoaded', async function () { + console.log("Loading..."); // @ts-expect-error - console.log("Loading Version:", __COMMIT_HASH__); + console.log("Build Data:", BUILD_STRING); i18next.init({ lng: pageState.language, fallbackLng: 'en', diff --git a/webpack.config.js b/webpack.config.js index 201b72c..3c04412 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,16 +1,20 @@ const path = require('path'); const webpack = require('webpack'); +var os = require("os"); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const { GitRevisionPlugin } = require('git-revision-webpack-plugin'); +const gitRevisionPlugin = new GitRevisionPlugin(); + + const VERBOSE = Object.getOwnPropertyNames(process.env).includes("VERBOSE") || !true; const MODE = process.env.WEBPACK_MODE || "production" const DEBUG = MODE != "production"; -let commitHash = require('child_process') - .execSync('git rev-parse --short HEAD') - .toString(); +let commitHash = gitRevisionPlugin.commithash(); + module.exports = { mode: MODE, @@ -29,7 +33,8 @@ module.exports = { new MiniCssExtractPlugin(), new HtmlWebpackPlugin({ title: "VaultUI" }), new webpack.DefinePlugin({ - __COMMIT_HASH__: JSON.stringify(commitHash), + BUILD_STRING: + JSON.stringify(`Built At: ${new Date().toString()} by ${os.userInfo().username}@${os.hostname()} on commit ${commitHash}`), }) ], devServer: {