62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
// @ts-check
|
|
|
|
const isProduction = process.env.NODE_ENV === "production";
|
|
|
|
const bundleAnalyzer = process.env.npm_config_argv?.includes(
|
|
"build:bundle-analyzer"
|
|
);
|
|
|
|
const webpack = require("webpack");
|
|
|
|
/**
|
|
* @type {import("next").NextConfig}
|
|
* */
|
|
const nextConfig = {
|
|
compiler: {
|
|
reactRemoveProperties: isProduction,
|
|
removeConsole: isProduction,
|
|
styledComponents: {
|
|
displayName: !isProduction,
|
|
minify: isProduction,
|
|
pure: true,
|
|
},
|
|
},
|
|
devIndicators: {
|
|
buildActivityPosition: "top-right",
|
|
},
|
|
experimental: {
|
|
legacyBrowsers: false,
|
|
swcFileReading: true,
|
|
},
|
|
optimizeFonts: false,
|
|
productionBrowserSourceMaps: false,
|
|
reactStrictMode: true,
|
|
swcMinify: !isProduction,
|
|
webpack: (config) => {
|
|
config.plugins.push(
|
|
new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
|
|
const mod = resource.request.replace(/^node:/, "");
|
|
|
|
switch (mod) {
|
|
case "buffer":
|
|
resource.request = "buffer";
|
|
break;
|
|
case "stream":
|
|
resource.request = "readable-stream";
|
|
break;
|
|
default:
|
|
throw new Error(`Not found ${mod}`);
|
|
}
|
|
})
|
|
);
|
|
|
|
return config;
|
|
},
|
|
};
|
|
|
|
module.exports = bundleAnalyzer
|
|
? require("@next/bundle-analyzer")({
|
|
enabled: isProduction,
|
|
})(nextConfig)
|
|
: nextConfig;
|