-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
41 lines (36 loc) · 998 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
38
39
40
41
import 'dotenv/config'
import config from './webpack.config.babel'
import express from 'express'
import morgan from 'morgan'
import path from 'path'
import webpack from 'webpack'
import { createReloadable, isDevelopment } from '@artsy/express-reloadable'
const { PORT } = process.env
const app = express()
if (isDevelopment) {
const compiler = webpack(config)
app.use(morgan('dev'))
app.use(require('webpack-hot-middleware')(compiler))
app.use(
require('webpack-dev-middleware')(compiler, {
publicPath: config.output.publicPath,
serverSideRender: true,
stats: 'errors-only',
})
)
const mountAndReload = createReloadable(app, require)
app.use(
mountAndReload(path.resolve(__dirname, 'src'), {
watchModules: ['react-relay-network-modern-ssr'],
})
)
} else {
app.use(require('src'))
}
app.listen(PORT, () => {
console.log(
isDevelopment
? `\n[App] Booting... \n`
: `\n[App] Started on http://localhost:5000 \n`
)
})