viject
Version:
A tool for migrating your React app from react-scripts (Create React App) to Vite
13 lines (12 loc) • 441 B
JavaScript
import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
import { appIndexHTML, oldIndexHTML } from "./paths.js";
export const moveIndexHTML = () => {
try {
const html = readFileSync(oldIndexHTML, "utf-8").replace(/<\/head>/, '<script type="module" src="src/index"></script></head>');
writeFileSync(appIndexHTML, html);
unlinkSync(oldIndexHTML);
}
catch (e) {
console.error(e);
}
};