-
Notifications
You must be signed in to change notification settings - Fork 15
/
next.config.js
39 lines (32 loc) · 1.13 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
const path = require('path');
const withPlugins = require('next-compose-plugins');
const withBundleAnalyzer = require('@next/bundle-analyzer');
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
// https://medium.com/ne-digital/how-to-reduce-next-js-bundle-size-68f7ac70c375
// https://medium.com/ne-digital/build-frontend-performance-monitor-dashboard-using-pagespeed-insights-e807a2caa6cf
module.exports = withPlugins(
[
withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
}),
],
{
reactStrictMode: true,
swcMinify: true,
eslint: {
dirs: ['src'],
},
webpack(config) {
config.resolve.alias = {
...config.resolve.alias,
// https://blog.usejournal.com/my-awesome-custom-react-environment-variables-setup-8ebb0797d8ac
environment: path.join(__dirname, 'src', 'environments', process.env.CLIENT_ENV || 'production'),
};
config.plugins = [
...config.plugins,
process.env.NODE_ENV === 'production' ? new DuplicatePackageCheckerPlugin() : null,
].filter(Boolean);
return config;
},
}
);