forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart
53 lines (42 loc) · 1.07 KB
/
start
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
#!/usr/bin/env node
'use strict'
const run = require('./run')
const express = require('express')
const webpack = require('webpack')
const configs = require('../app/webpack.development')
function startApp() {
const runningApp = run({ stdio: 'inherit' })
if (!runningApp) {
console.error(
"Couldn't launch the app. You probably need to build it first. Run `yarn build:dev`."
)
process.exit(1)
}
runningApp.on('close', () => {
process.exit(0)
})
}
if (process.env.NODE_ENV === 'production') {
startApp()
return
}
const [mainConfig, rendererConfig, askPassConfig] = configs
const server = express()
const compiler = webpack(rendererConfig)
const port = process.env.PORT || 3000
server.use(
require('webpack-dev-middleware')(compiler, {
publicPath: rendererConfig.output.publicPath,
noInfo: true,
})
)
server.use(require('webpack-hot-middleware')(compiler))
server.listen(port, 'localhost', err => {
if (err) {
console.log(err)
process.exit(1)
return
}
console.log(`Server running at http://localhost:${port}`)
startApp()
})