-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnext.config.js
100 lines (92 loc) · 3.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* cspell:disable */
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { createRequire } from 'module';
import CopyPlugin from 'copy-webpack-plugin';
const require = createRequire(import.meta.url);
const __dirname = fileURLToPath(dirname(import.meta.url));
const outputPath = fileURLToPath(new URL('./public', import.meta.url));
const polyfillsFolderPath = join(outputPath, './js/polyfills');
/** @type {import('next').NextConfig} */
export default {
experimental: {
esmExternals: true,
},
images: {
dangerouslyAllowSVG: false,
remotePatterns: [
{
hostname: 'images.unsplash.com',
},
{
hostname: 'tailwindui.com',
},
{
hostname: 'pbs.twimg.com',
},
],
},
async headers() {
return [
{
source: '/(.*)?', // Matches all pages
headers: [
{
key: 'X-Frame-Options',
value: 'DENY',
},
],
},
];
},
webpack: (config, context) => {
if (!config.plugins) config.plugins = [];
if (!config.module.rules) config.module.rules = [];
config.plugins.push(
...[
new context.webpack.IgnorePlugin({
resourceRegExp: /^(lokijs|pino-pretty|encoding)$/,
}),
new context.webpack.DefinePlugin({
'process.env.WEB3_CONSTANTS_RPC': process.env.WEB3_CONSTANTS_RPC ?? '{}',
'process.env.MASK_SENTRY_DSN': process.env.MASK_SENTRY_DSN ?? '{}',
'process.env.NODE_DEBUG': 'undefined',
'process.version': JSON.stringify('0.1.0'),
}),
new CopyPlugin({
patterns: [
{
context: join(__dirname, './src/maskbook/packages/polyfills/dist/'),
from: '*.js',
to: polyfillsFolderPath,
},
],
}),
],
);
config.experiments = {
...config.experiments,
backCompat: false,
asyncWebAssembly: true,
};
config.externals = [...(config.externals ?? []), '@napi-rs/image'];
config.resolve.extensionAlias = {
...config.resolve.extensionAlias,
'.js': ['.js', '.ts', '.tsx'],
'.mjs': ['.mts', '.mjs'],
};
config.resolve.extensions = ['.js', '.ts', '.tsx'];
config.resolve.conditionNames = ['mask-src', '...'];
config.resolve.fallback = {
...config.resolve.fallback,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer'),
zlib: require.resolve('zlib-browserify'),
'text-encoding': require.resolve('@sinonjs/text-encoding'),
};
return config;
},
};