1
0
Fork 0
mirror of https://github.com/bastienwirtz/homer.git synced 2026-07-17 16:38:59 +00:00

feat: Inject package.json version into the app

This commit is contained in:
Bastien Wirtz 2025-09-29 21:53:11 +02:00
parent 4904717db0
commit 81c7496264
3 changed files with 24 additions and 2 deletions

View file

@ -6,7 +6,14 @@ import eslintConfigPrettier from "@vue/eslint-config-prettier";
/** @type {import('eslint').Linter.Config[]} */ /** @type {import('eslint').Linter.Config[]} */
export default [ export default [
{ files: ["**/*.{js,mjs,cjs,vue}"] }, { files: ["**/*.{js,mjs,cjs,vue}"] },
{ languageOptions: { globals: globals.browser } }, {
languageOptions: {
globals: {
...globals.browser,
__APP_VERSION__: "readable",
},
},
},
pluginJs.configs.recommended, pluginJs.configs.recommended,
...pluginVue.configs["flat/recommended"], ...pluginVue.configs["flat/recommended"],
eslintConfigPrettier, eslintConfigPrettier,

View file

@ -54,7 +54,6 @@
/> />
</Navbar> </Navbar>
</div> </div>
<section id="main-section" class="section"> <section id="main-section" class="section">
<div v-cloak class="container"> <div v-cloak class="container">
<ConnectivityChecker <ConnectivityChecker
@ -154,6 +153,7 @@ export default {
this.buildDashboard(); this.buildDashboard();
window.onhashchange = this.buildDashboard; window.onhashchange = this.buildDashboard;
this.loaded = true; this.loaded = true;
console.info(`Homer v${__APP_VERSION__}`);
}, },
beforeUnmount() { beforeUnmount() {
window.onhashchange = null; window.onhashchange = null;

View file

@ -7,13 +7,28 @@ import process from "process";
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
import { version } from "./package.json";
function writeVersionPlugin() {
return {
name: "write-version",
closeBundle() {
fs.writeFileSync("dist/VERSION", version);
},
};
}
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
base: "", base: "",
build: { build: {
assetsDir: "resources", assetsDir: "resources",
}, },
define: {
__APP_VERSION__: JSON.stringify(version),
},
plugins: [ plugins: [
writeVersionPlugin(),
// Custom plugin to serve dummy-data JSON files without sourcemap injection // Custom plugin to serve dummy-data JSON files without sourcemap injection
{ {
name: "dummy-data-json-handler", name: "dummy-data-json-handler",