13 lines
613 B
JavaScript
13 lines
613 B
JavaScript
|
// 将当前时间写入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 id="build-time">.*<\/span>/, `<span id="build-time">${buildTime}</span>`);
|
||
|
fs.writeFileSync(distIndexPath, newIndexContent, 'utf-8');
|
||
|
console.log('build success');
|