Last active
November 30, 2022 21:13
-
-
Save emrergin/bf75a15be053c4994a24f9021dd25c09 to your computer and use it in GitHub Desktop.
Vite Unserved HTML Workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,`"./`); | |
writeFileSync('./dist/index.html',result); | |
} | |
modifyForLocal(basePath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment