Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt3: nitro.publicAssets does not copy custom dirs to .output/public #25185

Closed
pstatham-exp opened this issue Jan 13, 2024 · 4 comments · Fixed by #26163
Closed

Nuxt3: nitro.publicAssets does not copy custom dirs to .output/public #25185

pstatham-exp opened this issue Jan 13, 2024 · 4 comments · Fixed by #26163

Comments

@pstatham-exp
Copy link

Environment

Nuxt project info: 11:47:55 PM


  • Operating System: Linux
  • Node Version: v21.5.0
  • Nuxt Version: 3.9.1
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: npm@10.2.4
  • Builder: -
  • User Config: app, alias, css, devtools, nitro, modules, quasar, postcss, ssr
  • Runtime Modules: nuxt-quasar-ui@2.0.7
  • Build Modules: -

Reproduction

The StackBlitz and CodeSandbox do not allow .output/ directories, so cannot reproduce there

Describe the bug

Following the description of #18918 I am unable to add additional directories to the .output/public folder:

nitro: {
    publicAssets: [
      {
        baseURL: 'samples',
        dir: './samples',
        maxAge: 60 * 60 * 24 * 7
      }
    ]
  },

This assumes I have a directory called samples at the same level of the nuxt.config.ts.

When running npm run build, the .output/public does not contain this directory.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

Stackblitz does produce a .output/ folder, it's just hidden. So you are welcome to provide a Stackblitz reproduction.

Copy link
Contributor

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@marekbuxobucek
Copy link

marekbuxobucek commented Feb 1, 2024

@pstatham-exp As you can see it is semi-working.

It gives public access to serve content under dir path ignoring baseURL in nitro.publicAssets

reproduction
https://stackblitz.com/edit/github-9ukebr-ui1ppg?file=pages%2Findex.vue&file=nuxt.config.ts

steps to reproduce:

  • yarn build
  • node .output/server/index.mjs

it works until I change the img src in index.vue to use publicAssets.baseURL instead of publicAssets.dir path

@danielroe
Copy link
Member

We need to provide a resolver to let Vite know that the custom baseURL you provide matches that directory on disk. (We already do something very similar for layer public dirs.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants