javascripthtmles6-modulesvite

Vite preview is working but I can not see it running when opening index.html


I dont know if I'm doint it wrong here, but I started a vanilla.js project with vite, I did my code, and everything is working with: npm run dev (which runs vite command).

But when I run npm run build and I open /dist/index.html the page is not working.

Probably I'm doing something wrong.

I know that when I run npm run build && npm run preview it works. But I'm trying to make it work by only opening the index.html file, because AFAIK, that's the only way I could host it on Github pages.


Solution

  • I added this at vite.config.js and now it works!

    import { defineConfig } from 'vite';
    
    export default defineConfig({
      base: '/roulette-simulation/'
    });