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

vue: undefined path in production mode #188

Open
2 tasks done
zanmato opened this issue Nov 28, 2024 · 6 comments
Open
2 tasks done

vue: undefined path in production mode #188

zanmato opened this issue Nov 28, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@zanmato
Copy link
Contributor

zanmato commented Nov 28, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.0.0

Plugin version

1.0.0

Node.js version

22

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

24.04

Description

When running in production and using CACHE_DIR, outDir will be unset in the generated dist config, causing an undefined error here: https://github.com/fastify/fastify-vite/blob/dev/packages/fastify-vue/routing.js#L114-L115

However I'm not sure if it should be changed from build.outDir to fastify.clientOutDir (and remove the client/ prefix of the html path) or to make the dist config write the outDir value?

Link to code that reproduces the bug

No response

Expected Behavior

No response

@onlywei
Copy link
Collaborator

onlywei commented Nov 28, 2024

Try v8.0.0-alpha.2

@zanmato
Copy link
Contributor Author

zanmato commented Nov 29, 2024

Try v8.0.0-alpha.2

It's the same issue, my dist file in CACHE_DIR looks like this:

{
  "base": "/",
  "root": "/mnt/dev/src/workspace/frontend/client",
  "build": {
    "assetsDir": "assets"
  },
  "fastify": {
    "clientOutDir": "dist/client",
    "serverOutDir": "dist/server"
  }
}

As you can see build.outDir is unset, I think the best solution is probably to set it here https://github.com/fastify/fastify-vite/blob/dev/packages/fastify-vite/plugin.mjs#L38 then it will work both with and without the cached config

@onlywei onlywei added the bug Something isn't working label Dec 1, 2024
@onlywei
Copy link
Collaborator

onlywei commented Dec 1, 2024

Gotcha. I just tested this out and the vite.build.outDir is intentionally not set because it needs to be either the clientOutDir or the serverOutDir depending on which build is being executed by vite. Even if you unset CACHE_DIR and use the default behavior of find-cache-dir, it will not be set.

@galvez I believe the issue is within the @fastify/vue package in the line that @zanmato has reported.

@onlywei
Copy link
Collaborator

onlywei commented Dec 2, 2024

@zanmato are you using SSR?

@zanmato
Copy link
Contributor Author

zanmato commented Dec 2, 2024

@zanmato are you using SSR?

Yes, both SSR and CSR

@zanmato
Copy link
Contributor Author

zanmato commented Dec 2, 2024

I've already fixed a couple of issues in the vue rendering file in my PR #187
This is the last issue that I found, just didn't know which way you preferred to solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants