-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adds support for a client public folder #1229
Conversation
Signed-off-by: Mihovil Ilakovac <mihovil@ilakovac.com>
Signed-off-by: Mihovil Ilakovac <mihovil@ilakovac.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking quite good and very nice job on the Haskell code, it is looking very solid! Also clean!
There are some intricacies to how we handle file copying though, Wasp currently, that I will make sure to explain the best, as they might push this PR in a bit different direction.
So we have two ways of producing files in the generated project -> via file drafts, or via other methods. Other methods are "normal" ways -> copying files directly basically, per case. We do that for migrations, I think for something else also.
And file drafts -> we use that for all the user source code (external code), and we also use it for any files that we come up with in the Generator itself, be it based on templates or directly from memory or whatever.
So basically code itself we generate via file drafts, and a couple of things around it we handle directly (like migrations).
The benefit of file drafts (fds from now on) is that we have a system for writing them to disk, where we ensure that we don't write them if it is not needed. We also make sure there are no old file drafts laying around, that could mess up the generated project. And that all happens automatically, as long as you use file draft mechanism, so this is a preffered way of generating code in the generated Wasp project.
As for static assets -> since they are in the client/ dir, where the rest of the external code is -> I am thinking that we should actually probably also use the file drafts method! We could handle them similarly as we handle external code files. Actually, if you put them right now into public/ dir in client/, so in client/public/, don't they already get copied over by themselves, due to us copying over everything from client/?
The code that turns ext code dir into fds is in Wasp.ExternalCode -> readFiles. And it is called in a couple of places, one of them calling it on the client/. So hm, I am actually thinking now that it should get copied automatically, I would be surprised if it doesn't.
We are doing
Yes they do, but it's not good enough since it's copied in Behaviour before this PR: Behaviour after: |
Aha got it!
Did you mean: Can't we tell Vite to look into ext-src/public and that is it? Have you then ensured they are not also copied as external code files -> I guess they are also copied like that now then? One thing we could potentially do is edit |
It will work yes. But it feels off seeing Also, we already have a |
Yeah ok that is weird, since our stuff also goes in, that is true. |
waspc/src/Wasp/Generator/WebAppGenerator/ExternalCodeGenerator.hs
Outdated
Show resolved
Hide resolved
waspc/src/Wasp/Generator/WebAppGenerator/ExternalCodeGenerator.hs
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com>
Signed-off-by: Mihovil Ilakovac <mihovil@ilakovac.com>
Signed-off-by: Mihovil Ilakovac <mihovil@ilakovac.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@infomiho looking very good, I believe there is only one comment left open, the one with paths, prefixes and "/", check it out.
Signed-off-by: Mihovil Ilakovac <mihovil@ilakovac.com>
@@ -1872,6 +1872,25 @@ Make sure to pass in an object expected by the `QueryClient`'s constructor, as | |||
explained in | |||
[_react-query_'s docs](https://tanstack.com/query/v4/docs/react/reference/QueryClient). | |||
|
|||
## Public static files on the client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can they import stuff from there if they want? What can they do with the stuff that ends up there? What can they put there besides favicon.ico?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Left one tiny comment for docs, but this is it from me, I am all good. Looking nice!
Signed-off-by: Mihovil Ilakovac <mihovil@ilakovac.com>
Signed-off-by: Mihovil Ilakovac <mihovil@ilakovac.com>
Fixes #9
If the user created a
public
folder in the theirclient
folder -> it will get merged with the React app'spublic
folder.This means that users can expose client files at
/
more easily. It enables users to define a customfavicon.ico
.Left to do