forked from Synthetixio/staking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
84 lines (74 loc) · 2.56 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
82
83
84
const withPlugins = require('next-compose-plugins');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.GENERATE_BUNDLE_REPORT === 'true',
});
function optimiseContracts(config, { webpack }) {
const networks = ['goerli', 'goerli-ovm', 'mainnet', 'mainnet-ovm'];
const generate = require('./scripts/minify-synthetix-contract');
const out = require('path').resolve(__dirname, '.next/tmp');
require('fs').mkdirSync(out, { recursive: true });
generate({ networks, out });
networks.forEach((network) =>
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
new RegExp(`/synthetix/publish/deployed/${network}/deployment.json`),
require.resolve(`${out}/${network}.json`)
)
)
);
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
new RegExp('/synthetix/publish/deployed/(kovan|local)'),
require.resolve('./scripts/noop')
)
);
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/^synthetix$/, require.resolve('synthetix/index.js'))
);
}
module.exports = withPlugins([withBundleAnalyzer], {
swcMinify: true,
eslint: {
ignoreDuringBuilds: true,
},
webpack: (config, context) => {
config.resolve.mainFields = ['module', 'browser', 'main'];
if (!context.isServer) {
optimiseContracts(config, context);
}
config.module.rules.push({
test: /\.svg$/,
use: require.resolve('@svgr/webpack'),
});
config.module.rules.push({
test: /\.(png|jpg|ico|gif|woff|woff2|ttf|eot|doc|pdf|zip|wav|avi|txt|webp)$/,
type: 'asset',
generator: {
outputPath: './static/images',
publicPath: '/_next/static/images',
},
parser: {
dataUrlCondition: {
maxSize: 4 * 1024, // 4kb
},
},
});
return config;
},
trailingSlash: !!process.env.NEXT_PUBLIC_TRAILING_SLASH_ENABLED,
exportPathMap: function (defaultPathMap) {
return {
...defaultPathMap,
// all the dynamic pages need to be defined here (this needs to be imported from the routes)
'/staking': { page: '/staking/[[...action]]' },
'/staking/burn': { page: '/staking/[[...action]]' },
'/staking/mint': { page: '/staking/[[...action]]' },
'/earn': { page: '/earn/[[...pool]]' },
'/earn/claim': { page: '/earn/[[...pool]]' },
'/earn/curve-LP': { page: '/earn/[[...pool]]' },
'/earn/iBTC-LP': { page: '/earn/[[...pool]]' },
'/earn/iETH-LP': { page: '/earn/[[...pool]]' },
'/pools/weth-snx': { page: '/pools/[[...pool]]' },
};
},
});