start.js 1.47 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('../config/webpack.config.dev');
Christopher Chedeau's avatar
.    
Christopher Chedeau committed
15
var execSync = require('child_process').execSync;
16
var opn = require('opn');
Dan Abramov's avatar
Dan Abramov committed
17

Dan Abramov's avatar
Dan Abramov committed
18
19
20
21
22
23
24
25
26
27
28
29
var handleCompile;
if (process.argv[2] === '--smoke-test') {
  handleCompile = function (err, stats) {
    if (err || stats.toJson().errors.length || stats.toJson().warnings.length) {
      process.exit(1);
    } else {
      process.exit(0);
    }
  };
}

new WebpackDevServer(webpack(config, handleCompile), {
Dan Abramov's avatar
Dan Abramov committed
30
31
  publicPath: config.output.publicPath,
  historyApiFallback: true,
32
  hot: true, // Note: only CSS is currently hot reloaded
Dan Abramov's avatar
Dan Abramov committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  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
49
50
51
52
}).listen(3000, 'localhost', function (err, result) {
  if (err) {
    return console.log(err);
  }
53
  console.log('Running development server at http://localhost:3000/');
Christopher Chedeau's avatar
.    
Christopher Chedeau committed
54

55
  opn('http://localhost:3000/');
Dan Abramov's avatar
Dan Abramov committed
56
});