diff --git a/frontend/.env b/frontend/.env index cdd6e36..f469674 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,8 +1,17 @@ -VITE_PUBLIC_DIR = public -VITE_COLOR_PRIMARY = "#1b4965" -VITE_COLOR_SECONDARY = "#1c7293" -VITE_COLOR_BACKGROUND = "#f8f9fa" -VITE_DEFAULT_LOCALE = en -VITE_FALLBACK_LOCALE = en -VITE_APP_NAME = TrackIt -VITE_FIREBASE_CONFIG = {"apiKey":"AIzaSyASZh5cjJLkhXivX2DDzX69rhvj2mYBVCQ","authDomain":"trackit-f1b79.firebaseapp.com","projectId":"trackit-f1b79","storageBucket":"trackit-f1b79.appspot.com","messagingSenderId":"191629398412","appId":"1:191629398412:web:b60e6f94b5c6e3d0f506a9"} +VITE_APP_NAME=TrackIt +VITE_COLOR_PRIMARY="#1b4965" +VITE_COLOR_SECONDARY="#1c7293" +VITE_COLOR_BACKGROUND="#f8f9fa" +VITE_DEFAULT_LOCALE=en +VITE_FALLBACK_LOCALE=en +VITE_FIREBASE_CONFIG='{ + "apiKey": "AIzaSyASZh5cjJLkhXivX2DDzX69rhvj2mYBVCQ", + "authDomain": "trackit-f1b79.firebaseapp.com", + "projectId": "trackit-f1b79", + "storageBucket": "trackit-f1b79.appspot.com", + "messagingSenderId": "191629398412", + "appId": "1:191629398412:web:b60e6f94b5c6e3d0f506a9" +}' +VITE_PUBLIC_DIR=public +VITE_NPM_NAME=$npm_package_name +VITE_NPM_VERSION=$npm_package_version diff --git a/frontend/.env.development b/frontend/.env.development index 1c337fb..cb123a6 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,5 +1,12 @@ -VITE_PUBLIC_DIR = public.development -VITE_COLOR_PRIMARY = "#56693a" -VITE_COLOR_SECONDARY = "#779150" -VITE_APP_NAME = TrackIt-Dev -VITE_FIREBASE_CONFIG = {"apiKey":"AIzaSyBnndX-VxyIcXNEUD4njlhKAHEbYEadx7c","authDomain":"trackit-dev-fde62.firebaseapp.com","projectId":"trackit-dev-fde62","storageBucket":"trackit-dev-fde62.appspot.com","messagingSenderId":"587772691249","appId":"1:587772691249:web:0b43c740d50202d3db2610"} +VITE_APP_NAME=TrackIt-Dev +VITE_COLOR_PRIMARY="#56693a" +VITE_COLOR_SECONDARY="#779150" +VITE_FIREBASE_CONFIG='{ + "apiKey": "AIzaSyBnndX-VxyIcXNEUD4njlhKAHEbYEadx7c", + "authDomain": "trackit-dev-fde62.firebaseapp.com", + "projectId": "trackit-dev-fde62", + "storageBucket": "trackit-dev-fde62.appspot.com", + "messagingSenderId": "587772691249", + "appId": "1:587772691249:web:0b43c740d50202d3db2610" +}' +VITE_PUBLIC_DIR=public.development diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 4cfa86e..ec5aea3 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -12,6 +12,10 @@ module.exports = { parserOptions: { ecmaVersion: 2020, }, + globals: { + __VITE_MODE__: false, + __GIT_COMMIT__: false, + }, rules: { "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", diff --git a/frontend/env.d.ts b/frontend/env.d.ts index 7b3118e..3da6c8b 100644 --- a/frontend/env.d.ts +++ b/frontend/env.d.ts @@ -1,14 +1,19 @@ /// +declare const __VITE_MODE__: string; +declare const __GIT_COMMIT__: string; + interface ImportMetaEnv { - readonly VITE_PUBLIC_DIR: string; - readonly VITE_DEFAULT_LOCALE: string; - readonly VITE_FALLBACK_LOCALE: string; readonly VITE_APP_NAME: string; - readonly VITE_FIREBASE_CONFIG: string; readonly VITE_COLOR_PRIMARY: string; readonly VITE_COLOR_SECONDARY: string; readonly VITE_COLOR_BACKGROUND: string; + readonly VITE_DEFAULT_LOCALE: string; + readonly VITE_FALLBACK_LOCALE: string; + readonly VITE_FIREBASE_CONFIG: string; + readonly VITE_PUBLIC_DIR: string; + readonly VITE_NPM_NAME: string; + readonly VITE_NPM_VERSION: string; } interface ImportMeta { diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 20f0e24..13b4c24 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -53,6 +53,14 @@ app.config.globalProperties.$filters = { readableRelativeDateTime, }; +console.log( + "running %s v%s (%s, %s)", + import.meta.env.VITE_NPM_NAME, + import.meta.env.VITE_NPM_VERSION, + __VITE_MODE__, + __GIT_COMMIT__ +); + // see https://stackoverflow.com/questions/64175742/using-globalproperties-in-vue-3-and-typescript declare module "@vue/runtime-core" { interface ComponentCustomProperties { diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 97ccfed..bce82f0 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,5 +1,6 @@ import { fileURLToPath, URL } from "node:url"; import { resolve, dirname } from "node:path"; +import { execSync } from "node:child_process"; import { defineConfig, loadEnv } from "vite"; import vue from "@vitejs/plugin-vue"; @@ -8,9 +9,16 @@ import vuetify from "vite-plugin-vuetify"; import { VitePWA } from "vite-plugin-pwa"; // https://vitejs.dev/config/ +// https://vitejs.dev/config/#using-environment-variables-in-config export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd()); + const gitCommit = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim(); return { + // https://vitejs.dev/config/shared-options.html#define + define: { + __VITE_MODE__: JSON.stringify(mode), + __GIT_COMMIT__: JSON.stringify(gitCommit), + }, plugins: [ vue(), VueI18nPlugin({