I have a relative script tag inside my <head>
like this:
<script type="module" src="/../modules/module1"></script>
It is marked as being external via the vite/rollup config. During build, it is moved into the bundle and the path is adjusted based on the file system of the build agent (eg import "./modules/module1"
). However, the path is obviously not relative to the file system but the URL.
I tried a lot but I can't prevent the build from messing with that script tag or make vite/rollup understand that it's not relative to the current file system.
https://stackblitz.com/edit/vitejs-vite-gvcugb?file=index.html
Run npm i && npm run build
, check dist/index.html
and the first chars in dist/assets/index.*.js
and see the relative path has been moved and altered.
This functionality is apparently part of Vite: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/html.ts#L370
There it is marked for removal and file path resolution b/c the isExcluded
does not query config.build.rollupOptions.external
.
I created an issue to hopefully address this problem: https://github.com/vitejs/vite/issues/11017
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.