Skip to content

Commit

Permalink
Add flag option start-hot and apply env
Browse files Browse the repository at this point in the history
* Add flag option `start-hot` to server.js

* Apply env to `start-hot` mode of server.js
  • Loading branch information
jhen0409 authored Oct 31, 2016
1 parent 6025db3 commit d1ec63c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { spawn } from 'child_process';

import config from './webpack.config.development';

const argv = require('minimist')(process.argv.slice(2));

const app = express();
const compiler = webpack(config);
const PORT = process.env.PORT || 3000;
Expand All @@ -33,9 +35,11 @@ const server = app.listen(PORT, 'localhost', serverError => {
return console.error(serverError);
}

spawn('npm', ['run', 'start-hot'], { stdio: 'inherit' })
.on('close', code => process.exit(code))
.on('error', spawnError => console.error(spawnError));
if (argv['start-hot']) {
spawn('npm', ['run', 'start-hot'], { env: process.env, stdio: 'inherit' })
.on('close', code => process.exit(code))
.on('error', spawnError => console.error(spawnError));
}

console.log(`Listening at http://localhost:${PORT}`);
});
Expand Down

0 comments on commit d1ec63c

Please sign in to comment.