// 将当前时间写入dist/index.html console.log('start build'); const fs = require('fs'); const path = require('path'); const moment = require('moment'); const buildTime = moment().format('YYYY-MM-DD HH:mm:ss'); const indexPath = path.resolve(__dirname, 'index.html'); const distIndexPath = path.resolve(__dirname, 'dist/index.html'); const indexContent = fs.readFileSync(indexPath, 'utf-8'); const newIndexContent = indexContent.replace(/.*<\/span>/, `${buildTime}`); fs.writeFileSync(distIndexPath, newIndexContent, 'utf-8'); console.log('build success');