-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: build react-spa frontend #21
base: main
Are you sure you want to change the base?
Conversation
7a9d59d
to
efd7afd
Compare
efd7afd
to
908fb5e
Compare
I have the beginnings of something, although it breaks the CI... Works locally, I'll take a look in the week. Any themes in the community to use for styling? I'm a terrible designer ^^ |
I don't know why but tests in @galvez Do you know which fastify contributors have frontend skills to review my work, besides you? |
@jean-michelet I shall take a look this evening. |
@jean-michelet I cloned this repo jean-michelet:setup-spa and tried to start working on it to see the issue. Please forgive me and I'm not very fluent at setting up databases, but I have encountered the following errors that are preventing me from running
Then I tried
Was there a step I am missing? |
.env file missing? That could be a clue. 😅 |
Was I supposed to manually create my own .env file for this? I didn't see that in the Readme. |
@onlywei .env files are usually (always?) private. There's a sample given: https://github.com/fastify/demo/blob/main/.env.example Looking at https://github.com/fastify/demo/blob/main/package.json#L17 and following up with https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs I just learned about the new (node v20) argument --env. |
@millette Thanks. I just copied the
Next, I tried to add the following line into my
That didn't work, the result was the same, so next I tried:
Still the same result when running I went ahead and tried to run
|
The variables MYSQL_USER and MYSQL_PASSWORD are referenced in the |
export default { | ||
base: '/', | ||
root: resolve(import.meta.dirname, 'src/client'), | ||
plugins: [viteReact()] |
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.
Since you're using tsc
to build the server code into the dist
directory, I personally think it's kind of weird to have the client code built to src/client/dist
. I prefer to add the following here to the vite config:
build: {
emptyOutDir: true, // optional
outDir: resolve(import.meta.dirname, 'dist/client'),
}
Additionally, I'm trying to get this PR into fastify-vite
which gives another vite plugin called viteFastify()
that helps with production builds.
Thanks. Based on those docs here's what I tried: First, I tried to run Finally, I tried adding
After that, I ran |
Thanks for your review. I am gonna take a look to the issue tomorrow, I am off today. |
Can you:
And tell me if it's ok now? |
Also, I use Linux/Ubuntu and never used anything else since I learned programming so can you plz tell us if there specific Mac/Windows issues? |
I pulled the changes. Things are indeed different now, but still not working on my Mac. Here are the observations on my MacBook:
BTW I am using |
This is quite strange. I see |
Ah, ok I figured it out that because the There are 5 tests that are passing and 21 that are failing. Are those 21 the ones that you feel are related to fastify/vite? They seem to be complaining that the |
Yes, you have to generate a secret and set to JWT_SECRET, this is just a hmac. It ensures this is your application that sign the token and tests depends on it. This is just a random set of letters and digits. E.g. d7b3f2cfd0951e5b6c5e0bd0837af1ae951e8487b |
This is expected, we don't use NODE_ENV to determine what feature to use or not. |
@jean-michelet OK now we're cooking. I generated a random JWT_SECRET using:
And I put it into my .env file and now the tests run well. I humbly suggest adding these steps to the README.md file just in case anyone else is dumb like me and never did this before. As for the tests themselves, they actually all pass even when I forcibly register vite: Do I have to do something else to get them to fail? Note that I also commented out the one assertion in
|
Ok for the doc update. |
2580b5a
to
9e2a9ef
Compare
9e2a9ef
to
5af92f9
Compare
Ok now I see the time outs in an earlier CI build. Given that I'm not able to actually trigger the CI and test it myself, I can only offer some brute force suggestions. My first suggestion would be that there should be a new release of @fastify/vite out soon that contains a big change. Specifically it will include a vite plugin that I recommend that all users also use in their If that doesn't fix it, then the only thing I can think of to do next is to put |
Quality Gate failedFailed conditions |
Issue #20