vite: fix docker build (#2738)

## Description:

The sync-assets wasn't executing on docker-build. so instead just import
it from resources/ directory, vite logs a warning but I think that's
okay for now.

## 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:
Evan
2025-12-29 18:37:51 -08:00
committed by GitHub
parent b569e682e8
commit 4f3d9df46a
12 changed files with 44 additions and 111 deletions
-59
View File
@@ -1,59 +0,0 @@
import { promises as fs } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const root = path.resolve(__dirname, "..");
const resourcesDir = path.join(root, "resources");
const assetsDir = path.join(root, "src", "assets");
const dataDir = path.join(assetsDir, "data");
const langDir = path.join(assetsDir, "lang");
const dataFiles = ["version.txt", "countries.json", "QuickChat.json"];
async function ensureDir(dir) {
await fs.mkdir(dir, { recursive: true });
}
async function copyFile(src, dest) {
await ensureDir(path.dirname(dest));
await fs.copyFile(src, dest);
}
async function copyDataFiles() {
await Promise.all(
dataFiles.map((name) =>
copyFile(path.join(resourcesDir, name), path.join(dataDir, name)),
),
);
}
async function copyLangFiles() {
const sourceDir = path.join(resourcesDir, "lang");
const entries = await fs.readdir(sourceDir, { withFileTypes: true });
await Promise.all(
entries
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
.map((entry) =>
copyFile(
path.join(sourceDir, entry.name),
path.join(langDir, entry.name),
),
),
);
}
async function main() {
await ensureDir(dataDir);
await ensureDir(langDir);
await copyDataFiles();
await copyLangFiles();
console.log("Synced resources to src/assets.");
}
main().catch((error) => {
console.error("sync-assets failed:", error);
process.exit(1);
});