-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnext.config.js
37 lines (30 loc) · 1013 Bytes
/
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
require('dotenv-extended').load();
const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const { PHASE_PRODUCTION_SERVER } = require('next/constants');
module.exports = (phase) => {
const common = {
target: 'serverless',
env: {
MELON_SUBGRAPH: process.env.MELON_SUBGRAPH,
MELON_RATES_API: process.env.MELON_RATES_API,
},
};
if (phase === PHASE_PRODUCTION_SERVER) {
return common;
}
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: !!JSON.parse(process.env.ANALYZE || 'false'),
});
return withBundleAnalyzer({
...common,
webpack: (config, options) => {
config.resolve.alias = Object.assign({}, config.resolve.alias || {}, {
// Easy root level access to our file hierarcy.
'~': path.join(options.dir),
});
config.plugins = config.plugins.filter((plugin) => !(plugin instanceof ForkTsCheckerWebpackPlugin));
return config;
},
});
};