You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
705 B
24 lines
705 B
const ora = require('ora');
|
|
const chalk = require('chalk');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const prettyMs = require('pretty-ms');
|
|
|
|
module.exports = bundler => {
|
|
bundler.on('buildEnd', async () => {
|
|
if (process.env.NODE_ENV !== 'production') return;
|
|
console.log('');
|
|
const spinner = ora(chalk.grey('Fixing og:image link')).start();
|
|
const start = Date.now();
|
|
|
|
const htmlPath = path.join(bundler.options.outDir, 'index.html');
|
|
const html = fs.openSync(htmlPath).toString();
|
|
|
|
console.log(html);
|
|
|
|
const end = Date.now();
|
|
spinner.stopAndPersist({
|
|
symbol: '✨ ',
|
|
text: chalk.green(`Fixed og:image link in ${prettyMs(end - start)}.`)
|
|
});
|
|
};
|
|
|