prerender-spa-plugin-next

webpack 5 対応版、公式のやつはもうほぼメンテされてない。

https://github.com/tofandel/prerender-spa-plugin

webpack.js

const PrerenderSpaPlugin = require('prerender-spa-plugin-next')
new PrerenderSpaPlugin({
        staticDir: path.join(__dirname, 'dist'),
        routes: ['/', '/tos', '/uploaded', '/unsubscription', '/subscription', '/show', '/privacy', '/delete', '/dashboard'],
        minify: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          decodeEntities: true,
          keepClosingSlash: true,
          sortAttributes: true
        },
        renderer: require('@prerenderer/renderer-puppeteer'),
        rendererOptions: {
          args: ['--lang=ja']
        }
      }

--lang=ja で Puppeteer を日本語でレンダリングする。

home.vue

page() {
    return {
      title: this.$t('top.top'),
      meta: [{name: 'description', content: appConfig[this.$i18n.locale].description}],
      link: [
        { rel: 'canonical', href: 'https://uploader.xzy.pw' },
      ]
    }
  },