nuxt / vite

⚡ Vite Experience with Nuxt 2

Home Page:https://vite.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The vite's public folder conflicts with the nuxt's static folder.

yzqdev opened this issue · comments

Using nuxt-vite, special public directory is under your project root. Assets in this directory will be served at root path /; While using the command nuxt ,assets in the 'static' directory will be served at root path / ; So it is ambugious when we use nuxt-vite, we should use public as th root path / or the static folder as root path /?

Versions

nuxt-vite: v0.1.1
nuxt: 2.15.7

Reproduction

Now using the static as root path /, sometimes the images could be found ,sometime not;
the logo image could be found, while the default.png couldn't just as below
Below is my folder structure.
image

image

image

Description

I think updating the publicDir will work but after that, I got a different issue.

Reproduction

<template>
  <!-- /static/favicon.png -->
  <img src="/favicon.png" />
</template>
// nuxt.config.js
export default {
   // ...
   vite: {
     publicDir: resolve(__dirname, 'static'),
   }
}

Results

Terminal/cmd doesn't report any errors. But I got an error in the browser.

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "image/png".
Strict MIME type checking is enforced for module scripts per HTML spec.

TypeError: Failed to fetch dynamically imported module:

image