Skip to content

Commit 81c7496

Browse files
committed
feat: Inject package.json version into the app
1 parent 4904717 commit 81c7496

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

eslint.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import eslintConfigPrettier from "@vue/eslint-config-prettier";
66
/** @type {import('eslint').Linter.Config[]} */
77
export default [
88
{ files: ["**/*.{js,mjs,cjs,vue}"] },
9-
{ languageOptions: { globals: globals.browser } },
9+
{
10+
languageOptions: {
11+
globals: {
12+
...globals.browser,
13+
__APP_VERSION__: "readable",
14+
},
15+
},
16+
},
1017
pluginJs.configs.recommended,
1118
...pluginVue.configs["flat/recommended"],
1219
eslintConfigPrettier,

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
/>
5555
</Navbar>
5656
</div>
57-
5857
<section id="main-section" class="section">
5958
<div v-cloak class="container">
6059
<ConnectivityChecker
@@ -154,6 +153,7 @@ export default {
154153
this.buildDashboard();
155154
window.onhashchange = this.buildDashboard;
156155
this.loaded = true;
156+
console.info(`Homer v${__APP_VERSION__}`);
157157
},
158158
beforeUnmount() {
159159
window.onhashchange = null;

vite.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,28 @@ import process from "process";
77
import { defineConfig } from "vite";
88
import vue from "@vitejs/plugin-vue";
99

10+
import { version } from "./package.json";
11+
12+
function writeVersionPlugin() {
13+
return {
14+
name: "write-version",
15+
closeBundle() {
16+
fs.writeFileSync("dist/VERSION", version);
17+
},
18+
};
19+
}
20+
1021
// https://vitejs.dev/config/
1122
export default defineConfig({
1223
base: "",
1324
build: {
1425
assetsDir: "resources",
1526
},
27+
define: {
28+
__APP_VERSION__: JSON.stringify(version),
29+
},
1630
plugins: [
31+
writeVersionPlugin(),
1732
// Custom plugin to serve dummy-data JSON files without sourcemap injection
1833
{
1934
name: "dummy-data-json-handler",

0 commit comments

Comments
 (0)