Skip to content

Commit 856a136

Browse files
committed
Avoid stale JavaScript caching
1 parent 1470cc1 commit 856a136

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

frontend/package-lock.json

Lines changed: 30 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"antd": "^5.11.3",
2727
"bootstrap": "5.3.3",
2828
"jest-environment-jsdom": "^29.6.3",
29-
"joshi": "file:../build/js/packages/zero-joshi",
29+
"joshi": "file:../build/js/packages/zeroweb-joshi",
3030
"leaflet": "^1.9.4",
3131
"lodash": "^4.17.21",
3232
"memoize-immutable": "^3.0.0",
@@ -44,7 +44,7 @@
4444
"react-use-promise": "^0.5.0",
4545
"typescript": "^5.1.6",
4646
"web-vitals": "^2.1.4",
47-
"zero-zummon": "file:../build/js/packages/zero-zummon"
47+
"zero-zummon": "file:../build/js/packages/zeroweb-zummon"
4848
},
4949
"scripts": {
5050
"start": "vite --host 0.0.0.0",

frontend/vite.config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import {defineConfig} from "vite"
22
import react from "@vitejs/plugin-react"
3+
import {execSync} from "child_process"
4+
5+
// Put hash in file name so that the users don't get stale JS from their browser cache.
6+
const treeHash = execSync("git rev-parse HEAD:frontend").toString().trim().slice(0, 4)
37

48
export default defineConfig({
59
plugins: [react({ jsxImportSource: '@emotion/react' })],
@@ -8,12 +12,13 @@ export default defineConfig({
812
port: 3000,
913
},
1014
build: {
11-
minify: false,
15+
// minify: false,
1216
rollupOptions: {
17+
// Tree shaking seems too aggressive on the KotlinJS code
1318
treeshake: false,
1419
output: {
15-
entryFileNames: "[name].js",
16-
assetFileNames: '[name].css',
20+
entryFileNames: `[name].${treeHash}.js`,
21+
assetFileNames: `[name].${treeHash}.css`,
1722
},
1823
},
1924
},

0 commit comments

Comments
 (0)