-
Notifications
You must be signed in to change notification settings - Fork 3
/
next.config.js
44 lines (39 loc) · 1.12 KB
/
next.config.js
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
const { StatsWriterPlugin } = require('webpack-stats-plugin');
const filterWebpackStats =
require('@bundle-stats/plugin-webpack-filter').default;
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const { flowRight } = require('./utils/flow.js');
/**
* @type {import('next').NextConfig}
*/
const conf = {
pageExtensions: ['ts', 'tsx'],
images: {
formats: ['image/avif', 'image/webp'],
},
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);