0

我正在尝试使用 next + next-i18next 生成 ssg 项目。如果我在本地机器上构建我的项目,一切正常。我不能让它在生产中工作。生产版本在子类别中:example.com/app,这可能是问题所在(由于路径而找不到翻译文件)。

// 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,
    },
};
4

0 回答 0