bun-plugin-html icon indicating copy to clipboard operation
bun-plugin-html copied to clipboard

Browser Requests Incorrect Path for JavaScript File After Build

Open RedToxyl opened this issue 1 year ago • 0 comments

I have the following file structure:

.
└── src/
    └── index.html
    └── main.ts

In my index.html, I try to use <script type="module" src="./main.ts"></script>. When building it with your provided example script, main.ts and index.html get correctly converted, however now the browser tries to reach url/main.js which doesn't exist, instead of url/dist/main.js.

Trying to set a <base href="/dist/"> in index.html doesn't work, as now the HTMLParsers looks for ./src/dist/, which obviously doesn't exist. Neither does requesting <src="../src/main.ts". Maybe the tool could change occurrences of entry point to outdir/entrypoint?

I presume this is my own misunderstanding, but I'd be very grateful if you could take the time and run me through how to do this properly :)

RedToxyl avatar Jul 27 '24 13:07 RedToxyl