start.js 1.26 KB
Newer Older
Christopher Chedeau's avatar
Christopher Chedeau committed
1
2
3
4
5
6
7
8
9
/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

10
11
process.env.NODE_ENV = 'development';

Dan Abramov's avatar
Dan Abramov committed
12
13
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
14
var config = require('../webpack.config.dev');
Christopher Chedeau's avatar
.    
Christopher Chedeau committed
15
var execSync = require('child_process').execSync;
Dan Abramov's avatar
Dan Abramov committed
16
17
18
19

new WebpackDevServer(webpack(config), {
  publicPath: config.output.publicPath,
  historyApiFallback: true,
Dan Abramov's avatar
Dan Abramov committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  stats: {
    hash: false,
    version: false,
    timings: false,
    assets: false,
    chunks: false,
    modules: false,
    reasons: false,
    children: false,
    source: false,
    publicPath: false,
    colors: true,
    errors: true,
    errorDetails: true,
    warnings: true,
  }
Dan Abramov's avatar
Dan Abramov committed
36
37
38
39
40
}).listen(3000, 'localhost', function (err, result) {
  if (err) {
    return console.log(err);
  }
  console.log('Listening at http://localhost:3000/');
Christopher Chedeau's avatar
.    
Christopher Chedeau committed
41
42
43
44
45

  try {
    execSync('ps cax | grep "Google Chrome"');
    execSync('open -a "Google Chrome" http://localhost:3000/');
  } catch(e) {
46
    // Do nothing if Chrome isn't opened or cannot be opened
Christopher Chedeau's avatar
.    
Christopher Chedeau committed
47
  }
Dan Abramov's avatar
Dan Abramov committed
48
});