-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
81 lines (71 loc) · 2.23 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
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
72
73
74
75
76
77
78
79
80
81
const withAntdLess = require("next-plugin-antd-less");
const path = require("path");
/** @type {import('next').NextConfig} */
module.exports = withAntdLess({
// https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files
output: 'standalone',
reactStrictMode: true,
/**
* From Static structure: /about.html
* To Static structure: /about/index.html
*
* But this also make all client url end with a `/`, so we will turn it off
* https://nextjs.org/docs/api-reference/next.config.js/exportPathMap#adding-a-trailing-slash
*/
// trailingSlash: false,
// webpack(config) {
// return config;
// },
images: { loader: "custom" },
// sassOptions: {
// includePaths: [path.join(__dirname, 'styles')],
// },
/**
* Custom webpack config
* https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config
*/
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
/**
* Inject git commit id into debug page
*/
const git_commit_id = require("child_process")
.execSync("git rev-parse --short HEAD")
.toString()
.trim();
const stringReplaceLoaderRule = {
test: /pages\/lucis-debug\/index\.tsx$/,
loader: "string-replace-loader",
options: {
search: "LUCIS_VERSION_COMMIT_ID",
replace: git_commit_id,
},
};
const rules = config.module.rules;
rules.push(stringReplaceLoaderRule);
// Show testnet text on the header
const git_branch = require("child_process")
.execSync("cat .git/HEAD")
// .execSync('git branch --show-current')
.toString()
.trim();
rules.push({
test: /components\/Header\/Header\.tsx$/,
loader: "string-replace-loader",
options: {
search: '"IS_TESTNET"',
replace: (git_branch === "ref: refs/heads/trial").toString(),
},
});
console.log("gitBranch", git_branch);
rules.push({
test: /components\/Menu\/MenuMobile\.tsx$/,
loader: "string-replace-loader",
options: {
search: '"IS_TESTNET"',
replace: (git_branch === "ref: refs/heads/trial").toString(),
},
});
// Important: return the modified config
return config;
},
});