-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
151 lines (139 loc) · 4.14 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
require('dotenv').config()
const withPlugins = require('next-compose-plugins')
const withOptimizedImages = require('next-optimized-images')
/**
* Environment variables are passed in as strings. This means falsy values are
* implicitly converted to strings, which become truthy as a result.
*
* This function parses incoming variables and unconverts them, if necessary.
*
* @param {string} value
* @return mixed types
*/
function parse (value) {
switch (value) {
case 'null':
return null
case 'undefined':
return undefined
case 'false':
return false
case 'true':
return true
default: {
if (isNumeric(value)) {
return +value
} else {
return value
}
}
}
}
/* Tests if a string can be parsed as a number */
function isNumeric (num) {
return !Number.isNaN(num)
}
const nextConfig = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
// Important: return the modified config
config.module.rules.push({
test: /\.mp4$/i,
loader: 'file-loader',
options: {
outputPath: 'static/',
publicPath: '/_next/'
}
})
// Fix `i.willAdvance is not a function` error introduced with newer
// versions of Next.js. Solution borrowed from
// https://github.com/pmndrs/react-spring/issues/1078#issuecomment-752143468
config.module.rules.push({
test: /react-spring/,
sideEffects: true
})
return config
},
exportPathMap () {
// Let Next.js know where to find the entry page
// when it's exporting the static bundle for the use
// in the production version of your app
const slugs = [
'mary-church-terrell',
'florynce-kennedy',
'emma-gonzalez',
'jeannette-rankin',
'shirley-chisholm',
'women-in-the-116th-us-congress',
'alva-belmont',
'indra-nooyi',
'arlan-hamilton',
'grace-hopper',
'reshma-saujani',
'sabrina-gonzalez-pasterski',
'ida-b-wells',
'gloria-steinem',
'brittney-c-cooper',
'bernice-sandler',
'dawn-staley',
'mone-davis'
]
const paths = {
// Home page
'/': { page: '/' },
// Convenience attract-loop URLs
'/attract/1': { page: '/', query: { kioskId: 1 } },
'/attract/2': { page: '/', query: { kioskId: 2 } },
'/attract/3': { page: '/', query: { kioskId: 3 } },
'/attract/4': { page: '/', query: { kioskId: 4 } },
'/attract/5': { page: '/', query: { kioskId: 5 } },
'/attract/6': { page: '/', query: { kioskId: 6 } },
// Other pages
'/credits': { page: '/credits' },
'/pioneers': { page: '/pioneers' },
'/vote': { page: '/vote' }
}
// Define individual pioneer pages
slugs.forEach((slug) => {
paths[`/pioneers/${slug}`] = {
page: '/pioneers/[id]',
query: { id: slug, animated: true }
}
})
return paths
},
env: {
// Reference a variable that was defined in the .env file and make it available at Build Time
DEV_ADA_WIREFRAME: parse(process.env.DEV_ADA_WIREFRAME),
// Firebase
FIREBASE_API_KEY: process.env.FIREBASE_API_KEY,
FIREBASE_AUTH_DOMAIN: process.env.FIREBASE_AUTH_DOMAIN,
FIREBASE_DATABASE_URL: process.env.FIREBASE_DATABASE_URL,
FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID,
FIREBASE_STORAGE_BUCKET: process.env.FIREBASE_STORAGE_BUCKET,
FIREBASE_MESSAGING_SENDER_ID: process.env.FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_APP_ID: process.env.FIREBASE_APP_ID,
FIREBASE_MEASUREMENT_ID: process.env.FIREBASE_MEASUREMENT_ID
},
devIndicators: {
autoPrerender: false
},
target: 'server'
}
const optimizedImagesConfig = {
optimizeImagesInDev: false,
imageTrace: {
color: '#888888'
},
// Turn off inlining images as data-uri
inlineImageLimit: -1,
responsive: {
// We don't use `sharp` because there's issues with Electron
adapter: require('responsive-loader/jimp')
}
}
module.exports = withPlugins(
[[withOptimizedImages, optimizedImagesConfig]],
nextConfig
)