-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.mjs
53 lines (46 loc) · 1.45 KB
/
next.config.mjs
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
import fs from "node:fs";
import path, { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import createBundleAnalyzer from "@next/bundle-analyzer";
const withBundleAnalyzer = createBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
});
function getVersion() {
const packageRaw = fs.readFileSync("package.json");
const { version } = JSON.parse(packageRaw);
return version;
}
console.dir(process.env, { depth: null });
function copyPDFWorker() {
const cwd = dirname(fileURLToPath(import.meta.url));
const src = path.join(cwd, "node_modules", "pdfjs-dist", "build", "pdf.worker.js");
const dst = path.join(cwd, "public", "assets", "pdf.worker.js");
fs.copyFileSync(src, dst);
}
copyPDFWorker();
/** @type {import("next").NextConfig} */
const config = {
webpack: config => {
config.module.rules.push({
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: "raw-loader",
});
config.externals.push("find-up", "'node:path'", { "node:path": "commonjs path" }, "'node:fs'", {
"node:fs": "commonjs fs",
});
return config;
},
productionBrowserSourceMaps: true,
reactStrictMode: true,
poweredByHeader: false,
images: {
remotePatterns: [{ protocol: "https", hostname: "media.graphassets.com" }],
},
env: {
SITE_VERSION: getVersion(),
GIT_BRANCH: process.env.VERCEL_GIT_COMMIT_REF,
VERCEL_ENV: process.env.VERCEL_ENV,
},
};
export default withBundleAnalyzer(config);