diff --git a/Dockerfile b/Dockerfile index 66a0add..2b36581 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ COPY src src COPY .git .git # Set UI version -RUN echo "export const VERSION = '$(git describe --tag)'; export const COMMIT_HASH = '$(git rev-parse HEAD)';" > "src/shared/version.ts" +RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts" RUN yarn --production --prefer-offline RUN yarn build:prod diff --git a/dev.dockerfile b/dev.dockerfile index e446ba8..881d9bc 100644 --- a/dev.dockerfile +++ b/dev.dockerfile @@ -18,13 +18,12 @@ COPY generate_translations.js \ .babelrc \ ./ - COPY lemmy-translations lemmy-translations COPY src src COPY .git .git # Set UI version -RUN echo "export const VERSION = 'dev'; export const COMMIT_HASH = '$(git rev-parse HEAD)';" > "src/shared/version.ts" +RUN echo "export const VERSION = 'dev';" > "src/shared/version.ts" RUN yarn --prefer-offline RUN yarn build:dev diff --git a/package.json b/package.json index e5c1fa7..fcac4e1 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "scripts": { "analyze": "webpack --mode=none", "prebuild:dev": "yarn clean && node generate_translations.js", - "build:dev": "webpack --mode=development", + "build:dev": "webpack --env COMMIT_HASH=$(git rev-parse --short HEAD) --mode=development", "prebuild:prod": "yarn clean && node generate_translations.js", - "build:prod": "webpack --mode=production", + "build:prod": "webpack --env COMMIT_HASH=$(git rev-parse --short HEAD) --mode=production", "clean": "yarn run rimraf dist", "dev": "yarn build:dev --watch", "lint": "yarn translations:generate && tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx \"src/**\" && prettier --check \"src/**/*.{ts,tsx,js,css,scss}\"", diff --git a/src/server/index.tsx b/src/server/index.tsx index e9c907f..c6af347 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -2,7 +2,6 @@ import { setupDateFns } from "@utils/app"; import express from "express"; import path from "path"; import process from "process"; -import { COMMIT_HASH } from "../shared/version"; import CatchAllHandler from "./handlers/catch-all-handler"; import ManifestHandler from "./handlers/manifest-handler"; import RobotsHandler from "./handlers/robots-handler"; @@ -19,7 +18,10 @@ const [hostname, port] = process.env["LEMMY_UI_HOST"] server.use(express.json()); server.use(express.urlencoded({ extended: false })); -server.use(`/static/${COMMIT_HASH}`, express.static(path.resolve("./dist"))); +server.use( + `/static/${process.env.COMMIT_HASH}`, + express.static(path.resolve("./dist")) +); server.use(setCacheControl); if (!process.env["LEMMY_UI_DISABLE_CSP"] && !process.env["LEMMY_UI_DEBUG"]) { @@ -34,6 +36,7 @@ server.get("/css/themelist", ThemesListHandler); server.get("/*", CatchAllHandler); server.listen(Number(port), hostname, () => { + console.log(`HASH: ${process.env.COMMIT_HASH}`); setupDateFns(); console.log(`http://${hostname}:${port}`); }); diff --git a/src/server/utils/create-ssr-html.tsx b/src/server/utils/create-ssr-html.tsx index 0a4ec22..014d325 100644 --- a/src/server/utils/create-ssr-html.tsx +++ b/src/server/utils/create-ssr-html.tsx @@ -4,7 +4,6 @@ import serialize from "serialize-javascript"; import sharp from "sharp"; import { favIconPngUrl, favIconUrl } from "../../shared/config"; import { ILemmyConfig, IsoDataOptionalSite } from "../../shared/interfaces"; -import { COMMIT_HASH } from "../../shared/version"; import { buildThemeList } from "./build-themes-list"; import { fetchIconPng } from "./fetch-icon-png"; @@ -88,7 +87,9 @@ export async function createSsrHtml( - + ${helmet.link.toString() || fallbackTheme} @@ -103,7 +104,9 @@ export async function createSsrHtml(