4

I'm trying to generate ssg project with next + next-i18next. If I build my project on local machine everything works. I can't make it to work on production. Production version is in subcategory: example.com/app and that's probably the problem (can't find translation files because of paths).

// next-i18next.config.js
const path = require('path'); //eslint-disable-line

module.exports = {
    i18n: {
        defaultLocale: 'en',
        locales: [
            'en',
            'id',
            'bs',
        ],
    },
    localePath:
        process.env.NODE_ENV !== 'production'
            ? path.resolve('./public/locales/')
            : path.resolve('/app/public/locales/'), // attempt to make it work on production
    defaultNS: 'def',
    ns: ['def', 'overview', 'hint', 'bar_team', 'training', 'trans'],
    debug: process.env.NODE_ENV !== 'production',
    keySeparator: '/',
    interpolation: {
        escapeValue: false,
    },
    react: {
        useSuspense: false,
        wait: true,
    },
};

// next.config.js
const { i18n } = require('./next-i18next.config');

module.exports = {
    i18n,
    basePath: process.env.NODE_ENV !== 'production' ? '/app' : '',
    assetPrefix: '/app/',
    env: {
        REACT_APP_URL: process.env.REACT_APP_URL,
        REACT_APP_AUTH_LOGIN: process.env.REACT_APP_AUTH_LOGIN,
        REACT_APP_AUTH_PASS: process.env.REACT_APP_AUTH_PASS,
    },
};
juliomalves
  • 42,130
  • 20
  • 150
  • 146

0 Answers0