diff --git a/build.js b/build.js new file mode 100644 index 0000000..f132ccf --- /dev/null +++ b/build.js @@ -0,0 +1,15 @@ +const fs = require('fs'); +const path = require('path'); + +const indexPath = path.resolve(__dirname, 'dist/index.html'); +let indexHtml = fs.readFileSync(indexPath, 'utf-8'); +const timestamp = new Date().getTime(); + +// 正则表达式匹配JS文件引用并添加时间戳 +indexHtml = indexHtml.replace(/`; + } + return match; +}); +fs.writeFileSync(indexPath, indexHtml); \ No newline at end of file diff --git a/index.html b/index.html index ad859db..5d1ed2c 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,9 @@ + + + diff --git a/package.json b/package.json index 6e1dab7..9a0e692 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ "dev": "concurrently \"electron .\" \"cross-env BROWSER=none vite\"", "build": "vite build", "preview": "vite preview", - "build:dev": "vite build & electron-builder -w --config=./config/development.json", - "build:prod": "vite build & electron-builder -w --config=./config/production.json", - "build:xy": "vite build & electron-builder -w --config=./config/xy.json" + "build:dev": "vite build & node build.js & electron-builder -w --config=./config/development.json", + "build:prod": "vite build & node build.js & electron-builder -w --config=./config/production.json", + "build:xy": "vite build & node build.js & electron-builder -w --config=./config/xy.json" }, "agora_electron": { "platform": "win32", @@ -56,4 +56,4 @@ "vite-plugin-html": "^3.2.2", "vite-plugin-resolve": "^2.5.1" } -} +} \ No newline at end of file