mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*/
|
|
|
|
import path from 'path';
|
|
import {remarkPlugins} from './plugins/markdownToHtml.mjs';
|
|
import { createRequire } from 'module';
|
|
import {fileURLToPath} from 'node:url';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const redirects = require('./src/redirects.json');
|
|
|
|
export default {
|
|
pageExtensions: ['jsx', 'js', 'ts', 'tsx', 'mdx', 'md'],
|
|
experimental: {
|
|
plugins: true,
|
|
// TODO: this doesn't work because https://github.com/vercel/next.js/issues/30714
|
|
// concurrentFeatures: true,
|
|
scrollRestoration: true,
|
|
},
|
|
async redirects() {
|
|
return redirects.redirects;
|
|
},
|
|
env: {
|
|
// @todo Remove when https://github.com/vercel/next.js/pull/16529 lands
|
|
GA_TRACKING_ID: 'XXXX',
|
|
NEXT_PUBLIC_GA_TRACKING_ID: 'XXX',
|
|
},
|
|
rewrites() {
|
|
return [
|
|
{
|
|
source: '/feed.xml',
|
|
destination: '/_next/static/feed.xml',
|
|
},
|
|
];
|
|
},
|
|
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',
|
|
})
|
|
);
|
|
}
|
|
|
|
// Add our custom markdown loader in order to support frontmatter
|
|
// and layout
|
|
config.module.rules.push({
|
|
test: /.mdx?$/, // load both .md and .mdx files
|
|
use: [
|
|
options.defaultLoaders.babel,
|
|
{
|
|
loader: '@mdx-js/loader',
|
|
options: {
|
|
remarkPlugins,
|
|
},
|
|
},
|
|
fileURLToPath(new URL('./plugins/md-layout-loader', import.meta.url))
|
|
],
|
|
});
|
|
|
|
return config;
|
|
},
|
|
};
|