Skip to content

vike-vue: Can't get vue-i18n to work with +onCreateApp #1778

Closed Answered by s-ol
s-ol asked this question in Help & Questions
Discussion options

You must be logged in to vote

It seems this is down to vue-i18n misbehaving wrt global variables in a way that causes an Exception in node but not in browsers.
The following workaround get s things moving:

import type { OnCreateAppSync } from 'vike-vue';
import { i18n } from '../i18n';

export const onCreateApp: OnCreateAppSync = (pageContext) => {
  const { app } = pageContext;

  // workaround for vue-i18n SSR bug
  if (!('__VUE_PROD_DEVTOOLS__' in globalThis)) {
    (globalThis as any).__VUE_PROD_DEVTOOLS__ = false;
  }
  app.use(i18n);
}

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
5 replies
@s-ol
Comment options

@brillout
Comment options

@s-ol
Comment options

@brillout
Comment options

@s-ol
Comment options

Comment options

You must be logged in to vote
3 replies
@brillout
Comment options

@s-ol
Comment options

@brillout
Comment options

Answer selected by s-ol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants