-
Notifications
You must be signed in to change notification settings - Fork 306
Expand file tree
/
Copy pathnext.config.js
More file actions
78 lines (70 loc) · 2.05 KB
/
next.config.js
File metadata and controls
78 lines (70 loc) · 2.05 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
75
76
77
78
import withTM from 'next-transpile-modules'
import { fileURLToPath } from 'url'
import path from 'path'
import pkg from 'webpack'
const { ProvidePlugin, IgnorePlugin } = pkg
// Resolve __dirname for ESM
const __dirname = path.dirname(fileURLToPath(import.meta.url))
/** @type {import('next').NextConfig} */
const nextConfig = (phase, { defaultConfig }) => {
const config = {
experimental: {
esmExternals: 'loose'
},
webpack: (config, options) => {
config.module.rules.push(
{
test: /\.svg$/,
issuer: /\.(tsx|ts)$/,
use: [{ loader: '@svgr/webpack', options: { icon: true } }]
},
{
test: /\.gif$/,
type: 'asset/resource'
}
)
// Ignore electron imports
config.plugins.push(
new IgnorePlugin({
resourceRegExp: /^electron$/
})
)
// Configure resolve.fallback
const fallback = config.resolve.fallback || {}
Object.assign(fallback, {
http: path.resolve(__dirname, 'node_modules/stream-http'),
https: path.resolve(__dirname, 'node_modules/https-browserify'),
fs: false,
crypto: false,
os: false,
stream: false,
assert: false,
tls: false,
net: false
})
config.resolve.fallback = fallback
// Provide process and Buffer
config.plugins = (config.plugins || []).concat([
new ProvidePlugin({
process: path.resolve(__dirname, 'node_modules/process/browser'),
Buffer: [path.resolve(__dirname, 'node_modules/buffer'), 'Buffer']
})
])
// Apply defaultConfig.webpack if it’s a function
return typeof defaultConfig.webpack === 'function'
? defaultConfig.webpack(config, options)
: config
},
async redirects() {
return [
{
source: '/publish',
destination: '/publish/1',
permanent: true
}
]
}
}
return withTM(['@oceanprotocol/lib', '@oceanprotocol/ddo-js'])(config)
}
export default nextConfig