Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
88 lines (83 loc) · 2.55 KB
/
Copy pathnext.config.js
File metadata and controls
88 lines (83 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const { StatsWriterPlugin } = require('webpack-stats-plugin');
// The CJS build used to be `{ default: fn }` and is a bare `fn` as of 4.22 —
// accept either so a bump either way doesn't fail the build inside a webpack
// hook, where the error surfaces as an opaque `is not a function`.
const filterWebpackStatsModule = require('@bundle-stats/plugin-webpack-filter');
const filterWebpackStats =
filterWebpackStatsModule.default ?? filterWebpackStatsModule;
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const { flowRight } = require('./utils/flow.js');
/**
* @type {import('next').NextConfig}
*/
const conf = {
turbopack: {},
pageExtensions: ['ts', 'tsx'],
images: {
formats: ['image/avif', 'image/webp'],
},
// `/tools/*` and `/absurd-ui/*` were separate top-level sections before the
// experiments they held moved under `/experiments`. Nothing in the site links
// to the old paths any more, but they have been public for years — these keep
// the inbound links and search results alive.
async redirects() {
return [
{
source: '/tools/playground',
destination: '/experiments/playground',
permanent: true,
},
{
source: '/tools/claymorphism',
destination: '/experiments/claymorphism',
permanent: true,
},
{
source: '/tools/speech-to-text',
destination: '/experiments/speech-to-text',
permanent: true,
},
{
source: '/absurd-ui',
destination: '/experiments',
permanent: true,
},
{
source: '/absurd-ui/ballistic-slider',
destination: '/experiments/ballistic-slider',
permanent: true,
},
// The design tokens page it replaced.
{
source: '/about/tokens',
destination: '/design',
permanent: true,
},
];
},
webpack: (config, options) => {
const { dev, isServer } = options;
// Output webpack stats JSON file only for
// client-side/production build
if (!dev && !isServer) {
config.plugins.push(
new StatsWriterPlugin({
filename: '../webpack-stats.json',
stats: {
assets: true,
chunks: true,
modules: true,
},
transform: (webpackStats) => {
const filteredSource = filterWebpackStats(webpackStats);
return JSON.stringify(filteredSource);
},
}),
);
}
return config;
},
};
module.exports = flowRight(withBundleAnalyzer)(conf);