forked from sportstimes/f1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
67 lines (58 loc) · 1.86 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
const withPWA = require("next-pwa")
const nextTranslate = require('next-translate-plugin')
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');
const withPWA = require('next-pwa')({
// disable: !isProd,
dest: 'public',
skipWaiting: true,
register: true,
importScripts: ['firebase-messaging-sw.js']
})
return nextTranslate(withPWA({
typescript: {
ignoreBuildErrors: true,
},
webpack: (cfg) => {
cfg.module.rules.push(
{
test: /\.md$/,
loader: 'ignore-loader'
}
)
return cfg;
},
redirects: async function redirects() {
const rules = [];
// 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;
}
}))
}