Static html file missing after generation
Hello, locally when I use
yarn generate
. All my html files are correctly created. When I deploy my app on Amplify, I don't get these html files (missing index.html and all). Has anyone had this error before?
buildspec. yml
3 Replies
Hi @Rodrigue. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the knowledge sources, it appears that you're encountering an issue with deploying a statically generated Nuxt 3 application to AWS Amplify. This is a known issue that can occur when Amplify's platform configuration doesn't match your build settings. Let's address this problem:
1. First, it's important to note that your
buildspec.yml
file looks correct for a static site generation (SSG) with Nuxt 3. You're using yarn generate
which is equivalent to nuxi generate
, and you're correctly specifying the .output/public
directory as the baseDirectory
for artifacts Nuxt Docs: .output (https://nuxt.com/docs/guide/directory-structure/output).
2. The issue you're experiencing is likely related to how Amplify is configured to handle your application. As mentioned in a Stack Overflow post, Amplify might be detecting your app as a server-side rendering (SSR) application instead of a static site Stack Overflow: AWS Amplify - NUXT 3 deploy (https://stackoverflow.com/questions/78278760).
3. To resolve this, you need to update the platform configuration in Amplify. You can do this using the AWS CLI with the following command:
This command changes the platform from WEB_COMPUTE
(used for SSR) to WEB
(used for static sites) Stack Overflow: AWS Amplify - NUXT 3 deploy (https://stackoverflow.com/questions/78278760).
4. After updating the platform configuration, you should redeploy your application in the Amplify console.
5. If you still encounter issues, you might need to check your Nuxt configuration to ensure it's set up for static site generation. Make sure your nuxt.config.ts
file doesn't have ssr: false
, as this would create a client-side only application Nuxt Docs: Static Hosting (https://nuxt.com/docs/getting-started/deployment#static-hosting).
6. Additionally, you can add an amplify.yml
file to your project root with more detailed configuration if needed. Here's an example:
Nitro Docs: AWS Amplify (https://nitro.unjs.io/deploy/providers/aws-amplify#advanced-configuration)
If after trying these steps you still don't see your HTML files in the Amplify deployment, it would be worth checking your Amplify console logs for any specific error messages or reaching out to AWS support for further assistance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@104158078055763968> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
That's right, my application was in
WEB_COMPUTE
instead of WEB
. I used the command to change to WEB
and deployed a new version. Unfortunately, this didn't solve the problem because the index.html file wasn't generated on the platform. However locally everything is working well.
Strangely, my configuration regularly switches to WEB_COMPUTE
for no reason. So that was the problem. So now I need to understand why it doesn't stay in WEB
. So my nuxt 3
problem is solved. Thanks a lot!