2021-10-27 12:27:14 +02:00
|
|
|
module.exports = (phase, { defaultConfig }) => {
|
|
|
|
/**
|
|
|
|
* @type {import('next').NextConfig}
|
|
|
|
*/
|
|
|
|
const nextConfig = {
|
|
|
|
webpack: (config, options) => {
|
|
|
|
config.module.rules.push(
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
issuer: /\.(tsx|ts)$/,
|
|
|
|
use: [{ loader: '@svgr/webpack', options: { icon: true } }]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.gif$/,
|
|
|
|
// yay for webpack 5
|
|
|
|
// https://webpack.js.org/guides/asset-management/#loading-images
|
|
|
|
type: 'asset/resource'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
// for old ocean.js, most likely can be removed later on
|
2022-01-11 10:45:15 +01:00
|
|
|
config.plugins.push(
|
|
|
|
new options.webpack.IgnorePlugin({
|
|
|
|
resourceRegExp: /^electron$/
|
|
|
|
})
|
|
|
|
)
|
2022-02-14 17:27:36 +01:00
|
|
|
const fallback = config.resolve.fallback || {}
|
|
|
|
Object.assign(fallback, {
|
|
|
|
// crypto: require.resolve('crypto-browserify'),
|
|
|
|
// stream: require.resolve('stream-browserify'),
|
|
|
|
// assert: require.resolve('assert'),
|
|
|
|
// os: require.resolve('os-browserify'),
|
|
|
|
// url: require.resolve('url'),
|
|
|
|
http: require.resolve('stream-http'),
|
|
|
|
https: require.resolve('https-browserify'),
|
2021-10-27 12:27:14 +02:00
|
|
|
fs: false,
|
|
|
|
crypto: false,
|
|
|
|
os: false,
|
|
|
|
stream: false,
|
2022-01-17 18:10:35 +01:00
|
|
|
assert: false
|
2022-02-14 17:27:36 +01:00
|
|
|
})
|
|
|
|
config.resolve.fallback = fallback
|
2021-10-27 12:27:14 +02:00
|
|
|
|
2022-02-14 17:27:36 +01:00
|
|
|
config.plugins = (config.plugins || []).concat([
|
|
|
|
new options.webpack.ProvidePlugin({
|
|
|
|
process: 'process/browser',
|
|
|
|
Buffer: ['buffer', 'Buffer']
|
|
|
|
})
|
|
|
|
])
|
2021-10-27 12:27:14 +02:00
|
|
|
return typeof defaultConfig.webpack === 'function'
|
|
|
|
? defaultConfig.webpack(config, options)
|
|
|
|
: config
|
2022-04-26 12:09:51 +02:00
|
|
|
},
|
|
|
|
async redirects() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
source: '/publish',
|
|
|
|
destination: '/publish/1',
|
|
|
|
permanent: true
|
|
|
|
}
|
|
|
|
]
|
2021-10-27 12:27:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Prefer loading of ES Modules over CommonJS
|
|
|
|
// https://nextjs.org/blog/next-11-1#es-modules-support
|
|
|
|
// experimental: { esmExternals: true }
|
|
|
|
}
|
|
|
|
|
|
|
|
return nextConfig
|
|
|
|
}
|