vite-go icon indicating copy to clipboard operation
vite-go copied to clipboard

Support Vite Projects stored outside of Go project source

Open muellerkyle opened this issue 2 years ago • 2 comments

I ran into an issue where I was unable to get this library to find the package.json file from my vite project without having to make a modification.

I structure my projects so that my JS source sits along side my go source, like the following:

  • Project Root
    • src
      • Backend (Go Project)
      • Frontend (JS UI Project)

In this configuration, supplying a JSProjectPath cannot resolve the package.json file in any way. But, by adding a configuration option, we can let the library know that it needs to use the path "as given" to go look for the package.json file.

Summary of Changes

  • Added a configuration option so that Vite Projects kept outside of the main go project can be used. JSInExternalDir
  • Updated the README.md
  • I removed the embed check in the parsePackageJSON function, mostly as it's only used to initialize the path. But, but adding the check, it removes control away from a user of the library as they hit a code conditional that forces ignoring deliberate setting of the JSProjectPath parameter. vc.FS is then used regardless of it being embedded or not.

muellerkyle avatar Apr 13 '23 12:04 muellerkyle

This looks like an excellent addition. Let me see if I can come up with a test with it; I'll add it to your PR. Thanks.

torenware avatar Apr 13 '23 20:04 torenware

This looks like an excellent addition. Let me see if I can come up with a test with it; I'll add it to your PR. Thanks.

Is there any update on this? It would be a huge add to the project for go servers that are more complex

mperkins808 avatar Nov 30 '23 12:11 mperkins808