-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
next.config.js
75 lines (67 loc) · 2.25 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
const withPWA = require('@ducanh2912/next-pwa').default({
dest: 'public',
skipWaiting: true,
register: true,
importScripts: ['firebase-messaging-sw.js'],
});
const withNextIntl = require('next-intl/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');
return withNextIntl(
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: '/f1_p1_p2_p3_q_gp.ics',
permanent: true,
destination:
'https://files-f1.motorsportcalendars.com/f1-calendar_p1_p2_p3_qualifying_sprint_gp.ics',
},
{
source: '/download.php',
permanent: true,
destination:
'https://files-f1.motorsportcalendars.com/f1-calendar_p1_p2_p3_qualifying_sprint_gp.ics',
},
);
}
rules.push({
source: '/download/:file*',
destination: `https://files-${process.env.NEXT_PUBLIC_SITE_KEY}.motorsportcalendars.com/:file*`,
permanent: true,
});
return rules;
},
}),
);
};