-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostbuild.js
More file actions
24 lines (20 loc) · 798 Bytes
/
Copy pathpostbuild.js
File metadata and controls
24 lines (20 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { promises as fs } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const indexPath = resolve(__dirname, 'dist', 'index.html');
// update the `dist/index.html` to change `/assets` to `assets` so the App loads assets correctly
async function updateIndexHtml() {
try {
const data = await fs.readFile(indexPath, 'utf8');
const result = data.replace(/\/assets/g, 'assets');
await fs.writeFile(indexPath, result, 'utf8');
console.log('Successfully updated dist/index.html');
} catch (err) {
console.error('Error reading or writing index.html:', err);
// eslint-disable-next-line no-undef
process.exit(1);
}
}
updateIndexHtml();