-
Notifications
You must be signed in to change notification settings - Fork 113
/
next.config.js
82 lines (74 loc) · 2.21 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
/** @type {import('next').NextConfig} */
const webpack = require('webpack');
const withPWA = require('next-pwa');
const runtimeCaching = require('next-pwa/cache');
require('dotenv').config();
module.exports = withPWA({
env: {
URL: process.env.URL,
TWITTER: process.env.TWITTER,
DISCORD: process.env.DISCORD,
RPC_URL: process.env.RPC_URL,
},
reactStrictMode: true,
pwa: {
dest: 'public',
disable: process.env.NODE_ENV === 'development',
runtimeCaching,
},
...(process.env.NODE_ENV === 'production' && {
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
}),
webpack5: true,
webpack: (config, options) => {
config.ignoreWarnings = [/Failed to parse source map/];
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
stream: require.resolve('stream-browserify'),
fs: require.resolve('browserify-fs'),
});
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
]);
const experiments = config.experiments || {};
Object.assign(experiments, {
asyncWebAssembly: true,
syncWebAssembly: true,
topLevelAwait: true,
});
config.experiments = experiments;
const alias = config.resolve.alias || {};
Object.assign(alias, {
react$: require.resolve('react'),
});
config.resolve.alias = alias;
// Handle nextjs bug with wasm static files
patchWasmModuleImport(config, options.isServer);
return config;
},
});
function patchWasmModuleImport(config, isServer) {
config.experiments = Object.assign(config.experiments || {}, {
asyncWebAssembly: true,
});
config.optimization.moduleIds = 'named';
config.module.rules.push({
test: /\.wasm$/,
type: 'webassembly/async',
});
// TODO: improve this function -> track https://github.com/vercel/next.js/issues/25852
if (isServer) {
config.output.webassemblyModuleFilename = './../static/wasm/[modulehash].wasm';
} else {
config.output.webassemblyModuleFilename = 'static/wasm/[modulehash].wasm';
}
}