Skip to content
This repository has been archived by the owner on May 10, 2020. It is now read-only.

Commit

Permalink
feat(run/dev): pipe server webpack stdout to main process
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4x committed Jul 4, 2016
1 parent 3319d62 commit 74672c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions run/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ process.env.BABEL_ENV = 'browser'
process.env.NODE_ENV = 'development'

require('babel-register')
require('babel-polyfill')

const debug = require('debug')

Expand Down
10 changes: 7 additions & 3 deletions run/utils/start-render-server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from 'path'
import { execSync, fork } from 'child_process'
import { exec, fork } from 'child_process'

import debug from 'debug'
import open from 'open'
Expand All @@ -14,13 +14,17 @@ let server = null
let serverReload = false
let firstServerStart = true

const startServer = () => {
const asyncExec = (cmd, opts) => new Promise(r =>
exec(cmd, opts, (e) => { if (e) { throw e } else { r() } }).stdout.pipe(process.stdout))

const startServer = async () => {
const env = { ...process.env, DEBUG: 'dev,koa', BABEL_ENV: 'server' }

// compile first the server code,
// it will be re-compiled at every server restart
const webpackServerConfig = resolve(__dirname, '../../webpack/server.config.babel.js')
execSync(`webpack --config ${webpackServerConfig}`, { env, encoding: 'utf8' })
await asyncExec(`webpack --config ${webpackServerConfig}`, { env, encoding: 'utf8' })

debug('dev')('compiled server code updated')

// define `restartServer` function
Expand Down

0 comments on commit 74672c4

Please sign in to comment.