-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
56 lines (49 loc) · 1.38 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
const fs = require('fs')
const path = require('path')
const { NODE_ENV, NOTION_TOKEN, BLOG_INDEX_ID } = process.env
try {
fs.unlinkSync(path.resolve('.blog_index_data'))
} catch (_) {
/* non fatal */
}
try {
fs.unlinkSync(path.resolve('.blog_index_data_previews'))
} catch (_) {
/* non fatal */
}
const warnOrError =
NODE_ENV !== 'production'
? console.warn
: msg => {
throw new Error(msg)
}
if (!NOTION_TOKEN) {
// We aren't able to build or serve images from Notion without the
// NOTION_TOKEN being populated
warnOrError(
`\nNOTION_TOKEN is missing from env, this will result in an error\n` +
`Make sure to provide one before starting Next.js`
)
}
if (!BLOG_INDEX_ID) {
// We aren't able to build or serve images from Notion without the
// NOTION_TOKEN being populated
warnOrError(
`\nBLOG_INDEX_ID is missing from env, this will result in an error\n` +
`Make sure to provide one before starting Next.js`
)
}
module.exports = {
target: 'experimental-serverless-trace',
webpack(cfg, { dev, isServer }) {
// only compile build-rss in production server build
if (dev || !isServer) return cfg
const originalEntry = cfg.entry
cfg.entry = async () => {
const entries = { ...(await originalEntry()) }
entries['./scripts/build-rss.js'] = './src/lib/build-rss.ts'
return entries
}
return cfg
},
}