0

I develop my website using Nuxt3 and deploy it following the instructions here: https://v3.nuxtjs.org/getting-started/deployment#static-hosting

I successfully get dist and node server hosted web (running npx serve -o dist) also works well, But directly opening index.html in brower leads to a webpage rendered without any CSS and images.

I checked the generated html and found the assets path is like:

<link rel="modulepreload" href="/_nuxt/entry-1f8b74a8.mjs" as="script" crossorigin>

while my dist folder looks like:

dist
├── _nuxt
│   ├── entry-1f8b74a8.mjs
│   ├── entry.ff9830ad.css
│   ├── index-a3c0d3be.mjs
│   ├── index-e5b9c659.mjs
│   ├── index.072137e3.css
│   ├── lcdp-c28417d3.mjs
│   ├── manifest.json
│   ├── paper-b4b64fe8.mjs
│   └── paper.6897f003.css
├── imgs
│   ├── bg1.png
│   ├── bg2.png
│   └── other images...
└── index.html

I guess maybe the reason is that the assets path is wrong? What is the correct way to do the static website generation using nuxt3?

why
  • 59
  • 4
  • You're using SSR or SSG? For SSG or anything really, you need to run a server anyway nowadays as [explained here](https://stackoverflow.com/a/72103370/8816585). – kissu Nov 15 '22 at 18:02
  • Yeah, I'm using SSG... So you mean nowadays there's no way to deploy Nuxt3 as a purely static website to the static hosting, such as GitHub pages? – why Nov 16 '22 at 03:30
  • Github pages will run a small server for you too actually. Same goes for Netlify and Vercel (which are miles better than GH pages anyway). There is quite a ton of platforms being able to host a Nuxt3 app for free. Most of the platforms here have a free hosting cost for SSG: https://v3.nuxtjs.org/getting-started/deployment#supported-hosting-providers – kissu Nov 16 '22 at 03:32
  • This is exactly the problem I met... Even though I use the GitHub page to deploy my app, it doesn't work as well (CSS and mjs files are 404). – why Nov 16 '22 at 04:28
  • Just don't use GH pages, it's sub-par and has nothing special to offer when compared to Netlify/Vercel. – kissu Nov 16 '22 at 04:30
  • OK, thanks for your help! I will try some other hosting servers. – why Nov 16 '22 at 04:40
  • Keep us updated if you face any issues. – kissu Nov 16 '22 at 04:46
  • I successfully deployed it using Vercel and it works well. Many thanks for your help! – why Nov 16 '22 at 14:51

1 Answers1

1

OP achieved to properly deploy the app on Vercel, it's better than Github Pages on every way anyway.

kissu
  • 40,416
  • 14
  • 65
  • 133