1
0
Fork 0

Make main.ts print the commit short hash.

This commit is contained in:
Kitteh 2021-05-09 16:15:51 +01:00
parent c635c2c5c7
commit 67f9703a33
3 changed files with 16 additions and 2 deletions

View file

@ -17,7 +17,8 @@
"globals": {
"pageContent": "writable",
"module": "writable",
"process": "writable"
"process": "writable",
"__COMMIT_HASH__": "writable"
},
"rules": {
"no-unused-vars": [

View file

@ -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',

View file

@ -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",
},