nuxt package deployment stepping pit record

My personal blog is written in nuxt, and it was packaged into a static website using npm generate for the first time. In this way, I encountered a problem. I published an article, but my front-end page was not displayed. . .

I found the answer after reading the difference between Nuxt "generate" and "build" packaging methods . It turns out that after static packaging, all server-side rendered data is fixed at the moment of packaging. If the data changes, it can only be repackaged. (I personally think it is the same as writing a blog with hexo)

solution:

1. Use npm build to package into a web application

优点:一次打包,利于seo
缺点:要开node服务器,服务器压力大
注意:要在nuxt.config.js文件中设置target: 'server',(默认两个值:server和static,否则后端数据改变,前端数据将不会更新)

2. Npm generate is packaged, but a scheduled task needs to be added to the server, and the npm generate command should be executed regularly

优点:利于seo,服务器压力小
缺点:要加定时任务,多次打包
注意:要在nuxt.config.js文件中设置target: 'static',(默认两个值:server和static)

Guess you like

Origin blog.csdn.net/qq_42944436/article/details/113914326