Open pongells opened 1 day ago
Very very hacky workaround with a custom plugin:
{
name: "reorder-base-script",
transformIndexHtml(html) {
return html.replace(
/(<head>)([\s\S]*?)(<script type="module" crossorigin src="\.\/assets\/polyfills[^"]+"><\/script>)([\s\S]*?)(<base href="[^"]+" \/>)/,
(match, headOpen, headContent, scriptTag, rest, baseTag) => {
return `${headOpen}\n ${baseTag}\n ${headContent.trim()}\n ${scriptTag}`;
},
);
},
apply: "build",
enforce: "post",
},
probably can be simplified a bit..
Describe the bug
Polyfills are attached to index.html as first thing in
<head>
, this means they are loaded before<base href.. />
is set.In my case this results in:
which is wrong.
Reproduction
https://github.com/pongells/vite-legacy-repro
Steps to reproduce
Checkout repo then:
Go to:
http://localhost:4173/about/me
see polyfills not being loaded.
Summary:
<base href="/" />
to yourindex.html
filebase: ""
invite.config.ts
System Info
Used Package Manager
yarn
Logs
No response
Validations