WGShare.Client.Electron/build.js

15 lines
546 B
JavaScript

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(/<script type="module" crossorigin src="([^"]+)">/g, (match, p1) => {
if (p1.endsWith('.js')) {
return `<script type="module" crossorigin src="${p1}?t=${timestamp}"></script>`;
}
return match;
});
fs.writeFileSync(indexPath, indexHtml);