-
Notifications
You must be signed in to change notification settings - Fork 6
/
next.config.js
89 lines (80 loc) · 1.84 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
/** @type {import('next').NextConfig} */
const withPlugins = require('next-compose-plugins')
const { getAbsPath } = require('./scripts/fileSystem')
const nextPWA = require('next-pwa')
const appEnv = process.env.STORE_WEB_ENV
if (!appEnv) {
console.error('STORE_WEB_ENV env variable is not set', process.env.HSCI_STORE_WEB_ENV)
process.exit(1)
}
const { parsed: parsedEnvs } = require('dotenv').config({
path: getAbsPath(`env/${appEnv}.env`),
})
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.BUNDLE_ANALYZE === 'true',
})
const securityHeaders = [
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
]
const nextConfig = {
env: {
...parsedEnvs,
STORE_WEB_ENV: process.env.STORE_WEB_ENV,
},
trailingSlash: false,
basePath: '',
poweredByHeader: false,
optimizeFonts: true,
typescript: {
ignoreBuildErrors: false,
},
assetPrefix: process.env.STORE_WEB_ASSETS_BASE_URL,
async headers() {
return [
{
source: '/(.*)',
headers: [...securityHeaders],
},
]
},
async redirects() {
return []
},
async rewrites() {
return [
{
source: '/sw.js',
destination: '/js/sw.js',
},
{
source: '/sw.js.map',
destination: '/js/sw.js.map',
},
// {
// source: '/.well-known/apple-developer-merchantid-domain-association',
// destination: '/misc/apple-developer-merchantid-domain-association',
// },
]
},
}
const withNextPWA = [
nextPWA,
{
pwa: {
dest: 'public/js',
sw: 'sw.js',
scope: '/',
disable: appEnv.startsWith('local'),
register: true,
swSrc: './pwa/service-worker.js',
},
},
]
module.exports = withPlugins([withNextPWA, withBundleAnalyzer], nextConfig)