forked from epicweb-dev/epic-stack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
37 lines (33 loc) · 847 Bytes
/
index.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
import 'dotenv/config'
import * as fs from 'fs'
import chalk from 'chalk'
import closeWithGrace from 'close-with-grace'
import sourceMapSupport from 'source-map-support'
sourceMapSupport.install({
retrieveSourceMap: function (source) {
// get source file without the `file://` prefix or `?t=...` suffix
const match = source.match(/^file:\/\/(.*)\?t=[.\d]+$/)
if (match) {
return {
url: source,
map: fs.readFileSync(`${match[1]}.map`, 'utf8'),
}
}
return null
},
})
closeWithGrace(async ({ err }) => {
if (err) {
console.error(chalk.red(err))
console.error(chalk.red(err.stack))
process.exit(1)
}
})
if (process.env.MOCKS === 'true') {
await import('./tests/mocks/index.ts')
}
if (process.env.NODE_ENV === 'production') {
await import('./server-build/index.js')
} else {
await import('./server/index.ts')
}