mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 09:14:09 +00:00
Inject server env vars into index.html, including instance id (#2888)
## Description: Should fix the broken 1v1 on staging. The issue was that we had multiple staging environments, and the matchmaker would often route a player to a game on a different staging server, so the client couldn't find the game. So now each deployment has a unique id, and the matchmaker only connects players & servers that have the same instance id. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
+15
-25
@@ -1,5 +1,4 @@
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { execSync } from "child_process";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
@@ -11,19 +10,6 @@ import tsconfigPaths from "vite-tsconfig-paths";
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
let gitCommit = process.env.GIT_COMMIT;
|
||||
|
||||
if (!gitCommit) {
|
||||
try {
|
||||
gitCommit = execSync("git rev-parse HEAD").toString().trim();
|
||||
} catch (error) {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
console.warn("Unable to determine git commit:", error.message);
|
||||
}
|
||||
gitCommit = "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
const isProduction = mode === "production";
|
||||
@@ -50,16 +36,21 @@ export default defineConfig(({ mode }) => {
|
||||
|
||||
plugins: [
|
||||
tsconfigPaths(),
|
||||
createHtmlPlugin({
|
||||
minify: isProduction,
|
||||
entry: "/src/client/Main.ts",
|
||||
template: "index.html",
|
||||
inject: {
|
||||
data: {
|
||||
// In case we need to inject variables into HTML
|
||||
},
|
||||
},
|
||||
}),
|
||||
...(isProduction
|
||||
? []
|
||||
: [
|
||||
createHtmlPlugin({
|
||||
minify: false,
|
||||
entry: "/src/client/Main.ts",
|
||||
template: "index.html",
|
||||
inject: {
|
||||
data: {
|
||||
gitCommit: JSON.stringify("DEV"),
|
||||
instanceId: JSON.stringify("DEV_ID"),
|
||||
},
|
||||
},
|
||||
}),
|
||||
]),
|
||||
viteStaticCopy({
|
||||
targets: [
|
||||
{
|
||||
@@ -76,7 +67,6 @@ export default defineConfig(({ mode }) => {
|
||||
isProduction ? "" : "localhost:3000",
|
||||
),
|
||||
"process.env.GAME_ENV": JSON.stringify(isProduction ? "prod" : "dev"),
|
||||
"process.env.GIT_COMMIT": JSON.stringify(gitCommit),
|
||||
"process.env.STRIPE_PUBLISHABLE_KEY": JSON.stringify(
|
||||
env.STRIPE_PUBLISHABLE_KEY,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user