forked from sportstimes/f1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
72 lines (64 loc) · 2.09 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
const withPWA = require("next-pwa")
const nextTranslate = require('next-translate')
const {
PHASE_DEVELOPMENT_SERVER,
PHASE_PRODUCTION_BUILD,
} = require('next/constants')
module.exports = (phase) => {
const isDev = phase === PHASE_DEVELOPMENT_SERVER
const isProd = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1'
const isStaging =
phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1'
// Move _public/:site_key to public
require('./build/public-assets');
return withPWA(nextTranslate({
webpack: (cfg) => {
cfg.module.rules.push(
{
test: /\.md$/,
loader: 'frontmatter-markdown-loader',
options: { mode: ['react-component'] }
}
)
return cfg;
},
pwa: {
disable: !isProd,
dest: "public",
publicExcludes: ['!download/*', '!download/**/*'],
buildExcludes: ['!download/*', '!download/**/*'],
},
redirects: async function redirects() {
const rules = [];
if(process.env.NEXT_PUBLIC_MAINTENANCE_MODE === "true"){
rules.push(
{
source: "/*",
destination: "/maintenance",
permanent: false,
}
);
}
// Handle 2022 adjustment to separate sprint races out as a separate session.
// This allows users who generated a url prior to 2022 to get sprint sessions
// Without needing to regenerate the url for the new format.
if(process.env.NEXT_PUBLIC_SITE_KEY === "f1"){
rules.push(
{
source: '/download/:prefix*_q_\:suffix',
permanent: true,
destination: `https://files-${process.env.NEXT_PUBLIC_SITE_KEY}.motorsportcalendars.com/:prefix*_qualifying_sprint_\:suffix`,
}
);
}
rules.push(
{
source: "/download/:file*",
destination: `https://files-${process.env.NEXT_PUBLIC_SITE_KEY}.motorsportcalendars.com/:file*`,
permanent: true,
}
);
return rules;
}
}))
}