From ed33bf6fa697cf20133ee6fe1c8b9f24394ba3bd Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Fri, 21 Mar 2025 11:06:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.js | 15 +++++++++++++++ index.html | 3 +++ package.json | 8 ++++---- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 build.js 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 @@ + + +