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

WARN Instead of /public/index.html, use /index.html

Open gVguy opened this issue 3 years ago • 4 comments

In accordance to the readme, I have this config:

createHtmlPlugin({
  entry: 'src/main.ts',
  template: env.VITE_MODE == 'prod' ? 'public/index.prod.html' : 'public/index.html'
})

It works, but I'm getting this warning from vite:

WARN  files in the public directory are served at the root path.
Instead of /public/index.html, use /index.html.

I tried going with /index.html, but then the only thing I see is a blank page. It seems that script is not being injected.

Any Ideas for a fix? Thanks.

gVguy avatar Jul 18 '22 13:07 gVguy

I noticed, that if I manually include <script type="module" src="/src/main.ts"></script> in index.html, it works as expected.

But no matter what I do with the entry field inside config, it fails to auto-inject.

gVguy avatar Jul 18 '22 13:07 gVguy

I have the same problem. How can I solve it

GavanHub avatar Jul 20 '23 07:07 GavanHub

same issue public/index.html with <script type="module" src="/src/main.ts"></script> auto-inject not working

DreamUFO avatar Sep 14 '23 09:09 DreamUFO