-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
41 lines (33 loc) · 1.04 KB
/
next.config.mjs
File metadata and controls
41 lines (33 loc) · 1.04 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
import path from "node:path";
import { fileURLToPath } from "node:url";
const disabledPackages = ["pino-pretty", "lokijs", "encoding"];
const isTurbopack = Boolean(process.env.TURBOPACK);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const emptyModuleAbsolutePath = path.join(__dirname, "lib", "empty-module.ts");
const turbopackAliases = disabledPackages.reduce((aliases, pkg) => {
aliases[pkg] = "./lib/empty-module.ts";
return aliases;
}, {});
const webpackAliases = disabledPackages.reduce((aliases, pkg) => {
aliases[pkg] = emptyModuleAbsolutePath;
return aliases;
}, {});
/** @type {import('next').NextConfig} */
const nextConfig = {
turbopack: {
resolveAlias: turbopackAliases,
},
};
if (!isTurbopack) {
nextConfig.webpack = (config) => {
config.externals.push(...disabledPackages);
config.resolve = config.resolve ?? {};
config.resolve.alias = {
...(config.resolve.alias ?? {}),
...webpackAliases,
};
return config;
};
}
export default nextConfig;