Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf633450

Browse files
committed
Implement version checking and cache invalidation mechanism
1 parent9cc79e5 commitf633450

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

‎client/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name":"exploit-seek",
33
"private":true,
4-
"version":"1.0.0",
4+
"version":"1.2.0",
55
"type":"module",
66
"scripts": {
77
"dev":"vite --host",

‎client/src/main.jsx‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@ import ReactDOM from "react-dom/client";
33
importAppfrom"./App.jsx";
44
import"./index.css";
55

6+
// Version checking function
7+
constcheckVersion=()=>{
8+
constcurrentVersion=__APP_VERSION__;
9+
constlastVersion=localStorage.getItem('app_version');
10+
11+
if(lastVersion!==currentVersion){
12+
localStorage.setItem('app_version',currentVersion);
13+
// Clear cache and reload if version changed
14+
if('caches'inwindow){
15+
caches.keys().then((names)=>{
16+
names.forEach(name=>{
17+
caches.delete(name);
18+
});
19+
});
20+
}
21+
window.location.reload(true);
22+
}
23+
};
24+
25+
// Check version only on app load
26+
checkVersion();
27+
628
ReactDOM.createRoot(document.getElementById("root")).render(
729
<React.StrictMode>
830
<App/>

‎client/vite.config.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
import{defineConfig}from"vite";
22
importreactfrom"@vitejs/plugin-react";
3+
importpkgfrom'./package.json';
34

45
exportdefaultdefineConfig({
56
plugins:[react()],
67
server:{
78
host:'0.0.0.0',
89
port:8080
10+
},
11+
build:{
12+
rollupOptions:{
13+
output:{
14+
// Add hash to chunk filenames
15+
chunkFileNames:'assets/[name]-[hash].js',
16+
entryFileNames:'assets/[name]-[hash].js',
17+
assetFileNames:'assets/[name]-[hash].[ext]'
18+
}
19+
},
20+
// Add timestamp to make sure the browser always fetches the latest version
21+
manifest:true,
22+
// Generate source maps for better debugging
23+
sourcemap:true
24+
},
25+
define:{
26+
__APP_VERSION__:JSON.stringify(pkg.version),
927
}
1028
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp