-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
71 lines (64 loc) · 1.84 KB
/
next.config.mjs
File metadata and controls
71 lines (64 loc) · 1.84 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
// @ts-check
/** @typedef {(config?: import("next").NextConfig | undefined) => import("next").NextConfig} NextConfigPlugin */
import withBundleAnalyzerInit from "@next/bundle-analyzer";
import MonacoWebpackPlugin from "monaco-editor-webpack-plugin";
const withBundleAnalyzer = withBundleAnalyzerInit({
enabled: process.env.ANALYZE === "true",
});
/** @type {import("next").NextConfig} */
const nextConfig = {
reactStrictMode: true,
output: process.env.BUILD_STANDALONE === "true" ? "standalone" : undefined,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "www.gravatar.com",
},
],
},
transpilePackages: ["monaco-editor"],
/**
* @param {import("webpack").Configuration} config
*/
webpack(config, { isServer }) {
if (!config.plugins) {
config.plugins = [];
}
// Only add Monaco plugin for client-side builds
if (!isServer) {
const monacoPlugin = new MonacoWebpackPlugin({
languages: ["cpp", "python", "java"],
filename: "static/[name].worker.js",
globalAPI: false,
});
// @ts-ignore Monaco's webpack types don't seem to be compatible.
config.plugins.push(monacoPlugin);
}
return config;
},
experimental: {
optimizePackageImports: [
"@/features/auth",
"@/features/about",
"@/features/rankings",
"@/features/problems",
"@/features/submissions",
"@/utils",
"@/components",
"@/hooks",
"@/components/icon",
],
},
};
/** @type {NextConfigPlugin[]} */
const plugins = [withBundleAnalyzer];
/**
* @type {(
* phase: string,
* { defaultConfig }: { defaultConfig: import("next").NextConfig },
* ) => import("next").NextConfig}
*/
const nextComposePlugins = () =>
plugins.reduce((acc, plugin) => plugin(acc), nextConfig);
export default nextComposePlugins;