-
-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathnext.config.js
More file actions
74 lines (71 loc) · 2.11 KB
/
next.config.js
File metadata and controls
74 lines (71 loc) · 2.11 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
72
73
74
require("@app/config");
const compose = require("lodash/flowRight");
const {
ROOT_URL,
T_AND_C_URL,
BUCKET,
AWSACCESSKEYID,
AWSSECRETKEY,
AWS_REGION,
} = process.env;
if (!ROOT_URL) {
throw new Error("ROOT_URL is a required envvar");
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(function(process = null) {
// You *must not* use `process.env` in here, because we need to check we have
// those variables. To enforce this, we've deliberately shadowed process.
module.exports = () => {
const withCss = require("@zeit/next-css");
const withLess = require("@zeit/next-less");
const lessToJS = require("less-vars-to-js");
const fs = require("fs");
const path = require("path");
// Where your antd-custom.less file lives
const themeVariables = lessToJS(
fs.readFileSync(
path.resolve(__dirname, "../assets/antd-custom.less"),
"utf8"
)
);
// fix: prevents error when .less files are required by node
if (typeof require !== "undefined") {
require.extensions[".less"] = () => {};
}
return compose(
withCss,
withLess
)({
serverRuntimeConfig: {
BUCKET: BUCKET,
AWSACCESSKEYID: AWSACCESSKEYID,
AWSSECRETKEY: AWSSECRETKEY,
AWS_REGION: AWS_REGION,
},
poweredByHeader: false,
distDir: `../.next`,
exportTrailingSlash: true,
lessLoaderOptions: {
javascriptEnabled: true,
modifyVars: themeVariables, // make your antd custom effective
},
webpack(config, { webpack, dev, isServer }) {
if (dev) config.devtool = "cheap-module-source-map";
return {
...config,
plugins: [
...config.plugins,
new webpack.DefinePlugin({
"process.env.ROOT_URL": JSON.stringify(ROOT_URL),
"process.env.T_AND_C_URL": JSON.stringify(T_AND_C_URL || null),
}),
],
externals: [
...(config.externals || []),
isServer ? { "pg-native": "pg/lib/client" } : null,
].filter(_ => _),
};
},
});
};
})();