when React project is deployed, js and css are not loaded by the index.html !! #9008
-
Describe the bugHello, I don't know if it's a (huge) bug, or due to my ignorance I'm missing something. In this case please forgive me... (NOTE: I was not able to include both the lines of the code, because when I publish this post the 2nd line is automatically deleted) <script type="module" crossorigin src="/assets/index.bda214ef.js"></script>As you will see the relative path for both "js" and "css" is missing the "." at the beginning. So, I had to manually modify both the path, adding the "." at the beginning, in this way: <script type="module" crossorigin src="./assets/index.bda214ef.js"></script>Now it's working, but I'm wondering why I had to do that! Many thanks for your help to understand this issue Reproductionhttps://github.com/issimissimo/Ciakk_React.git System Infonpm init vite@latest
.... create my code with React JS
npm ruin build Used Package Managernpm LogsNo response Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
maybe use |
Beta Was this translation helpful? Give feedback.
-
in package.json replace vite build with vite build --base=./ , this worked for me, you are free to provide any base path here according to your need |
Beta Was this translation helpful? Give feedback.
-
Modifying the path is not working for me giving me this error after removing the crossorigin and type module its giving this |
Beta Was this translation helpful? Give feedback.
-
import React from 'react'; const Home = () => { ); }; export default Home; |
Beta Was this translation helpful? Give feedback.
in package.json replace vite build with vite build --base=./ , this worked for me, you are free to provide any base path here according to your need