Files
outline-ru/tools/patches/vite.patch
T
Evgeny 4485a10514 hot reload (#24)
* container with hot reload

* update readme
2025-07-05 08:18:15 +05:00

36 lines
1.3 KiB
Diff

diff --git a/server/routes/index.ts b/server/routes/index.ts
index 26fbded27..478de1922 100644
--- a/server/routes/index.ts
+++ b/server/routes/index.ts
@@ -103,7 +103,7 @@ router.get("/locales/:lng.json", async (ctx) => {
await send(ctx, path.join(lng, "translation.json"), {
setHeaders: (res, _, stats) => {
res.setHeader("Last-Modified", formatRFC7231(stats.mtime));
- res.setHeader("Cache-Control", `public, max-age=${7 * Day.seconds}`);
+ res.setHeader("Cache-Control", "no-store");
res.setHeader(
"ETag",
crypto.createHash("md5").update(stats.mtime.toISOString()).digest("hex")
diff --git a/vite.config.ts b/vite.config.ts
index 32b52d44e..26d611fee 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -45,6 +45,17 @@ export default () =>
: { strict: true },
},
plugins: [
+ {
+ name: 'reload',
+ configureServer(server) {
+ const { ws, watcher } = server;
+ watcher.on('change', file => {
+ if (file.endsWith('build/shared/i18n/locales/ru_RU/translation.json')) {
+ ws.send({ type: 'full-reload' });
+ }
+ });
+ },
+ },
// https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme
react({
babel: {