在尝试配置 next-i18next 包(版本 6)时,我的 next.js 配置文件出现问题,并且还有一个用于音频的 webpack 配置和一个用于图像的插件。直到升级一切都很好,但现在没有加载我设置的 defaultLanguage。
我的 next.config.js 看起来像这样:
const withImages = require('next-images');
const { nextI18NextRewrites } = require('next-i18next/rewrites');
const localeSubpaths = { en: 'en' };
module.exports = withImages({
webpack(config, options) {
const { isServer } = options;
config.module.rules.push({
test: /\.(ogg|mp3|wav|mpe?g)$/i,
exclude: config.exclude,
use: [
{
loader: require.resolve('url-loader'),
options: {
limit: config.inlineImageLimit,
fallback: require.resolve('file-loader'),
publicPath: `${config.assetPrefix}/_next/static/images/`,
outputPath: `${isServer ? '../' : ''}static/images/`,
name: '[name]-[hash].[ext]',
esModule: config.esModule || false,
},
},
],
});
return config;
},
rewrites: async () => nextI18NextRewrites(localeSubpaths),
publicRuntimeConfig: {
localeSubpaths,
},
});
任何帮助,将不胜感激。