Skip to content

Commit 94581a8

Browse files
committed
fix: locales serving
1 parent 2b79e9d commit 94581a8

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

backend/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ if (
5151
["/app", "/app/*"],
5252
express.static(path.join(__dirname, "..", "frontend", "build"))
5353
);
54+
app.use(
55+
["/locales", "/locales/*"],
56+
express.static(path.join(__dirname, "..", "frontend", "build", "locales"))
57+
);
5458
app.get(["/app/network/*"], function (req, res) {
5559
res.sendFile(path.join(__dirname, "..", "frontend", "build", "index.html"));
5660
});

frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"rimraf": "^5.0.5",
4242
"source-map-explorer": "^2.5.3",
4343
"typescript": "^5.2.2",
44-
"vite": "^4.4.11"
44+
"vite": "^4.4.11",
45+
"vite-plugin-static-copy": "^1.0.6"
4546
},
4647
"scripts": {
4748
"start": "vite",

frontend/vite-plugin-generate-locales.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as url from "url";
44

55
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
66

7-
export default function GenerateLocalesPlugin() {
7+
export default function generateLocalesPlugin() {
88
return {
99
name: "generate-locales",
1010
buildStart() {

frontend/vite.config.js renamed to frontend/vite.config.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import process from "node:process";
22
import { defineConfig, searchForWorkspaceRoot } from "vite";
33
import react from "@vitejs/plugin-react";
4-
import GenerateLocalesPlugin from "./vite-plugin-generate-locales.js";
4+
import { viteStaticCopy } from "vite-plugin-static-copy";
5+
import generateLocalesPlugin from "./vite-plugin-generate-locales.js";
56

67
export default defineConfig({
78
base: "/app",
@@ -29,5 +30,16 @@ export default defineConfig({
2930
outDir: "build",
3031
chunkSizeWarningLimit: 1000,
3132
},
32-
plugins: [react(), GenerateLocalesPlugin()],
33+
plugins: [
34+
react(),
35+
generateLocalesPlugin(),
36+
viteStaticCopy({
37+
targets: [
38+
{
39+
src: "public/locales",
40+
dest: "",
41+
},
42+
],
43+
}),
44+
],
3345
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"dev": "concurrently \"cd frontend && cross-env FAST_REFRESH=true yarn start\" \"cd backend && cross-env NODE_ENV=development ZU_DEFAULT_USERNAME=admin ZU_DEFAULT_PASSWORD=zero-ui nodemon ./bin/www --ignore data/db.json\"",
1717
"build": "cd frontend && cross-env GENERATE_SOURCEMAP=false yarn build",
1818
"prod": "cd backend && cross-env NODE_ENV=production ZU_SECURE_HEADERS=false yarn start",
19+
"docker:build": "docker build . -t dec0dos/zero-ui -f docker/zero-ui/Dockerfile --progress=plain",
20+
"docker:run": "docker run --rm --env-file .env -e ZU_CONTROLLER_ENDPOINT=http://host.docker.internal:9993 -p 4000:4000 --name zero-ui dec0dos/zero-ui",
1921
"release": "standard-version && git push --follow-tags origin main && git add CHANGELOG.md",
2022
"commit": "yarn git-cz"
2123
},

yarn.lock

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ __metadata:
23762376
languageName: node
23772377
linkType: hard
23782378

2379-
"chokidar@npm:^3.5.2":
2379+
"chokidar@npm:^3.5.2, chokidar@npm:^3.5.3":
23802380
version: 3.6.0
23812381
resolution: "chokidar@npm:3.6.0"
23822382
dependencies:
@@ -4246,7 +4246,7 @@ __metadata:
42464246
languageName: node
42474247
linkType: hard
42484248

4249-
"fast-glob@npm:^3.2.9":
4249+
"fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.9":
42504250
version: 3.3.2
42514251
resolution: "fast-glob@npm:3.3.2"
42524252
dependencies:
@@ -4535,6 +4535,7 @@ __metadata:
45354535
styled-components: "npm:^5.3.11"
45364536
typescript: "npm:^5.2.2"
45374537
vite: "npm:^4.4.11"
4538+
vite-plugin-static-copy: "npm:^1.0.6"
45384539
languageName: unknown
45394540
linkType: soft
45404541

@@ -4550,7 +4551,7 @@ __metadata:
45504551
languageName: node
45514552
linkType: hard
45524553

4553-
"fs-extra@npm:^11.0.0":
4554+
"fs-extra@npm:^11.0.0, fs-extra@npm:^11.1.0":
45544555
version: 11.2.0
45554556
resolution: "fs-extra@npm:11.2.0"
45564557
dependencies:
@@ -9344,6 +9345,20 @@ __metadata:
93449345
languageName: node
93459346
linkType: hard
93469347

9348+
"vite-plugin-static-copy@npm:^1.0.6":
9349+
version: 1.0.6
9350+
resolution: "vite-plugin-static-copy@npm:1.0.6"
9351+
dependencies:
9352+
chokidar: "npm:^3.5.3"
9353+
fast-glob: "npm:^3.2.11"
9354+
fs-extra: "npm:^11.1.0"
9355+
picocolors: "npm:^1.0.0"
9356+
peerDependencies:
9357+
vite: ^5.0.0
9358+
checksum: 10c0/997114571bd429481974483465ab78d1ecd5fc48d2de06cbfe9dbf005f9b870aa072b0d9c22e2fd8def759db2c48ad662a6a0cdf47706fba409c82db7c03ed22
9359+
languageName: node
9360+
linkType: hard
9361+
93479362
"vite@npm:^4.4.11":
93489363
version: 4.5.3
93499364
resolution: "vite@npm:4.5.3"

0 commit comments

Comments
 (0)