forked from quran/quran.com-frontend-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
93 lines (86 loc) · 3.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* eslint-disable no-param-reassign */
const path = require('path');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE_BUNDLE === 'true',
});
// const { withSentryConfig } = require('@sentry/nextjs'); // disabled temporarily until next 12 supports it: https://github.com/vercel/next.js/discussions/30137#discussioncomment-1538436
const withPlugins = require('next-compose-plugins');
const withFonts = require('next-fonts');
const withPWA = require('next-pwa');
const runtimeCaching = require('next-pwa/cache');
const nextTranslate = require('next-translate');
const securityHeaders = require('./configs/SecurityHeaders.js');
const isDev = process.env.NEXT_PUBLIC_VERCEL_ENV === 'development';
const config = {
images: {
formats: ['image/avif', 'image/webp'],
domains: ['cdn.qurancdn.com', 'vercel.com', 'now.sh', 'quran.com', 'static.quran.com'],
},
pwa: {
disable: isDev,
dest: 'public',
runtimeCaching,
publicExcludes: ['!fonts/v1/**/*', '!fonts/v2/**/*'],
},
// this is needed to support importing audioWorklet nodes. {@see https://github.com/webpack/webpack/issues/11543#issuecomment-826897590}
webpack: (webpackConfig) => {
webpackConfig.resolve = {
...webpackConfig.resolve,
alias: {
...webpackConfig.resolve.alias,
'audio-worklet': path.resolve(__dirname, 'src/audioInput/audio-worklet.ts'),
},
};
webpackConfig.module.parser = {
...webpackConfig.module.parser,
javascript: {
worker: ['AudioWorklet from audio-worklet'],
},
};
webpackConfig.module.rules.push({
test: /\.svg$/i,
issuer: { and: [/\.(js|ts)x?$/] },
use: [
{
loader: '@svgr/webpack',
options: {
prettier: false,
svgo: true,
svgoConfig: { plugins: [{ removeViewBox: false }] },
},
},
],
});
return webpackConfig;
},
SentryWebpackPluginOptions: {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
},
async headers() {
return isDev
? []
: [
{
source: '/:route*', // apply security rules to all routes.
headers: securityHeaders,
},
{
source: '/fonts/:font*', // match wildcard fonts' path which will match any font file on any level under /fonts.
headers: [
{
key: 'cache-control',
value: 'public, max-age=31536000, immutable', // Max-age is 1 year. immutable indicates that the font will not change over the expiry time.
},
],
},
];
},
};
module.exports = withPlugins([withBundleAnalyzer, withPWA, withFonts, nextTranslate], config);