feat(nuxi): warn when prerendering routes with `ssr: false` (#18783)

This commit is contained in:
Daniel Roe 2023-02-06 15:25:53 -08:00 committed by GitHub
parent 39747ce095
commit 85881b462b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -76,8 +76,8 @@ By default, the workload gets distributed to the workers with the round robin st
There are two ways to deploy a Nuxt application to any static hosting services:
- Static site generation (SSG) pre-renders routes of your application at build time.
- Using `ssr: false` to produce a pure client-side output.
- Static site generation (SSG) with `ssr: true` pre-renders routes of your application at build time. (This is the default behaviour when running `nuxi generate`.) It will also generate `/200.html` and `/404.html` single-page app fallback pages, which can render dynamic routes or 404 errors on the client (though you may need to configure this on your static host).
- Alternatively, you can prerender your site with `ssr: false` (static single-page app). This will produce HTML pages with an empty `<div id="__nuxt"></div>` where your Vue app would normally be rendered. You will lose many of the benefits of prerendering your site, so it is suggested instead to use `<ClientOnly>` to wrap the portions of your site that cannot be server rendered (if any).
### Crawl-based Pre-rendering

View File

@ -52,6 +52,9 @@ export default defineNuxtCommand({
await buildNuxt(nuxt)
if (args.prerender) {
if (!nuxt.options.ssr) {
consola.warn('HTML content not prerendered because `ssr: false` was set. You can read more in `https://nuxt.com/docs/getting-started/deployment#static-hosting`.')
}
// TODO: revisit later if/when nuxt build --prerender will output hybrid
const dir = nitro?.options.output.publicDir
const publicDir = dir ? relative(process.cwd(), dir) : '.output/public'