import fs from 'fs';
import path from 'path';
process.chdir('dist');
const manifestPath = path.join('.vite', 'manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
let indexHtml = fs.readFileSync('index.html', 'utf-8');
const files = [
{ dst: 'assets/logo.svg', src: manifest['assets/logo.svg'].file },
{ dst: 'assets/index.css', src: manifest['index.html'].css[0] },
{ dst: 'assets/index.js', src: manifest['index.html'].file }
];
files.forEach(({ dst, src }) => {
indexHtml = indexHtml.replace(`/${src}`, dst);
fs.renameSync(src, dst);
});
fs.writeFileSync('index.html', indexHtml, 'utf-8');