Skip to content

Instantly share code, notes, and snippets.

View emrergin's full-sized avatar
😎

Emre Ergin emrergin

😎
View GitHub Profile
@emrergin
emrergin / viteWorkaround.js
Last active November 30, 2022 21:13
Vite Unserved HTML Workaround
import { readFileSync,writeFileSync } from 'fs';
const basePath='ENTERBASEPATHHERE';
function modifyForLocal(basePath){
const regex = new RegExp('"'+basePath, "g");
const htmlToBeUpdated = readFileSync( './dist/index.html', {encoding:'utf8', flag:'r'});
const result = htmlToBeUpdated.replace(/type="module" crossorigin/g, "defer")
.replace(regex,`"./`);