Files
react.dev/next.config.js
dan a35b64cb33 Add <meta> tags for translations (#5930)
* Add site config with domain name

* Add <meta> tags for languages

* Move legacy redirect out of vercel config

This lets us give it a more specific subdomain per lang.

* Support sites with no legacy

* Fix types

* Undo unrelated change
2023-04-18 03:47:43 +01:00

89 lines
2.4 KiB
JavaScript

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
const siteConfig = require('./src/siteConfig').siteConfig;
/**
* @type {import('next').NextConfig}
**/
const nextConfig = {
pageExtensions: ['jsx', 'js', 'ts', 'tsx', 'mdx', 'md'],
reactStrictMode: true,
experimental: {
plugins: true,
scrollRestoration: true,
legacyBrowsers: false,
browsersListForSwc: true,
},
redirects() {
const redirects = [];
const languageCode = siteConfig.languageCode;
const subdomain =
languageCode === 'en' || !siteConfig.hasLegacySite
? ''
: languageCode + '.';
return [
{
// Assume all *.html links are legacy site URLs.
source: '/:path*(\\.html)',
destination: `https://${subdomain}legacy.reactjs.org/:path*.html`,
permanent: false,
},
];
},
env: {
SANDPACK_BARE_COMPONENTS: process.env.SANDPACK_BARE_COMPONENTS,
},
webpack: (config, {dev, isServer, ...options}) => {
if (process.env.ANALYZE) {
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: options.isServer
? '../analyze/server.html'
: './analyze/client.html',
})
);
}
// Don't bundle the shim unnecessarily.
config.resolve.alias['use-sync-external-store/shim'] = 'react';
const {IgnorePlugin, NormalModuleReplacementPlugin} = require('webpack');
config.plugins.push(
new NormalModuleReplacementPlugin(
/^@stitches\/core$/,
require.resolve('./src/utils/emptyShim.js')
),
new NormalModuleReplacementPlugin(
/^raf$/,
require.resolve('./src/utils/rafShim.js')
),
new NormalModuleReplacementPlugin(
/^process$/,
require.resolve('./src/utils/processShim.js')
),
new IgnorePlugin({
checkResource(resource, context) {
if (
/\/eslint\/lib\/rules$/.test(context) &&
/\.\/[\w-]+(\.js)?$/.test(resource)
) {
// Skips imports of built-in rules that ESLint
// tries to carry into the bundle by default.
// We only want the engine and the React rules.
return true;
}
return false;
},
})
);
return config;
},
};
module.exports = nextConfig;