Relative Path in Generated index.html #5081
Answered
by
fmstuff
miswanting
asked this question in
Q&A
-
No matter which one I choose below: <script type="module" src="./index.ts"></script> <script type="module" src="/index.ts"></script> <script type="module" src="index.ts"></script> The generated result will always be like this: <script type="module" crossorigin src="/assets/index.a3377d47.js"></script>
<link rel="modulepreload" href="/assets/vendor.98ac8201.js">
<link rel="stylesheet" href="/assets/index.163c7cae.css"> What I really want is: <script type="module" crossorigin src="assets/index.a3377d47.js"></script>
<link rel="modulepreload" href="assets/vendor.98ac8201.js">
<link rel="stylesheet" href="assets/index.163c7cae.css"> or <script type="module" crossorigin src="./assets/index.a3377d47.js"></script>
<link rel="modulepreload" href="./assets/vendor.98ac8201.js">
<link rel="stylesheet" href="./assets/index.163c7cae.css"> I'm asking this because it really matters when used in Electron. |
Beta Was this translation helpful? Give feedback.
Answered by
fmstuff
Oct 23, 2021
Replies: 1 comment 1 reply
-
How I solved it for my project: in your Configuring it like this in your import { defineConfig } from "vite";
// https://vitejs.dev/config/
export default defineConfig({
base: "./",
// your other configuration...
}); See also the Vixe docs for more details: https://vitejs.dev/config/#base |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
miswanting
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How I solved it for my project:
in your
vite.config.js
you can specify abase
field (which defaults to/
), and set it to e.g../
to produce relative links to assets in yourindex.html
.Configuring it like this in your
vite.config.js
should solve your problem:See also the Vixe docs for more details: https://vitejs.dev/config/#base