-
Notifications
You must be signed in to change notification settings - Fork 9
/
next.config.js
119 lines (109 loc) · 2.68 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* eslint-disable @typescript-eslint/no-var-requires */
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
// const path = require('path')
// const Dotenv = require('dotenv-webpack')
// Required by Docker
require('dotenv').config()
const nextConfig = {
target: 'server',
images: {
domains: ['app.subsocial.network', 'polkaverse.com', 'localhost', 'ipfs.io', 'grillapp.net'],
},
experimental: {
scrollRestoration: true,
},
transpilePackages: ['react-tweet'],
webpack: (config, { isServer }) => {
// This code for webpack 4
// if (!isServer) {
// config.node = {
// fs: 'empty'
// }
// }
// This code for webpack 5
if (!isServer) {
config.resolve.fallback.fs = false
}
config.plugins = config.plugins || []
config.plugins = [
...config.plugins,
// // Read the .env file
// new Dotenv({
// path: path.join(__dirname, '.env'),
// systemvars: true, // Required by Docker
// }),
]
config.module.rules.push(
{
test: /\.(raw)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'raw-loader',
},
{
test: /\.md$/,
use: ['html-loader', 'markdown-loader'],
},
{
test: /\.(png|svg|eot|otf|ttf|woff|woff2|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 8192,
publicPath: '/_next/static/',
outputPath: 'static/',
name: '[name].[ext]',
},
},
},
)
return config
},
}
module.exports = withBundleAnalyzer({
...nextConfig,
async redirects() {
const spaceId = ':spaceId(\\d{1,}|@.*)'
const slug = ':slug(.*\\d{1,})*'
const spacePage = '/:spaceId*'
const postPage = '/:spaceId/:slug*'
// Redirects for all URL formats. DO NOT REMOVE!
return [
{
source: '/spaces/all',
destination: '/spaces',
permanent: true,
},
{
source: `/spaces/${spaceId}`,
destination: spacePage,
permanent: true,
},
{
source: `/spaces/${spaceId}/about`,
destination: `${spacePage}/about`,
permanent: true,
},
{
source: `/spaces/${spaceId}/posts/${slug}`,
destination: postPage,
permanent: true,
},
{
source: `/${spaceId}/posts/${slug}`,
destination: postPage,
permanent: true,
},
{
source: '/dd/register',
destination: '/dd',
permanent: true,
},
{
source: '/faucet',
destination: 'https://discord.gg/ps2mvkST3x',
permanent: true,
},
]
},
})