To generate a Nuxt static generated app from the Nuxt universal SSR app, we will use the sample website we created in the previous chapters for this exercise. You can find this sample in /chapter-14/deployment/sample-website/ in our GitHub repository. So let's get cracking with the following steps:
-
Make sure you have the following "generate" run script in the package.json file as follows:
"scripts": {
"generate": "nuxt generate"
}
- Change the target project in the Nuxt config file to static:
// nuxt.config.js
export default {
target: 'static'
}
- Generate the 404 page by configuring the generate option in the Nuxt config file:
// nuxt.config.js
export default {
generate: {
fallback: true
}
}
Nuxt does not generate your custom 404 page, nor its default one. If you want to include this page in your static app, you can set fallback: true in the generate option in...