-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced react-hot-loader with webpack-hot-middleware
Hot loading remains in a separate process to allow server reloading Also unifies babel configs in .babelrc
- Loading branch information
Showing
7 changed files
with
76 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
{ | ||
"stage": 0, | ||
"loose": "all" | ||
"optional": "runtime", | ||
"loose": "all", | ||
"plugins": [ | ||
"typecheck" | ||
], | ||
"env": { | ||
"development": { | ||
"plugins": [ | ||
"typecheck", | ||
"react-transform" | ||
], | ||
"extra": { | ||
"react-transform": [{ | ||
"target": "react-transform-webpack-hmr", | ||
"imports": ["react"], | ||
"locals": ["module"] | ||
}] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
// enable runtime transpilation to use ES6/7 in node | ||
require('babel/register')({ | ||
stage: 0, | ||
plugins: ['typecheck'] | ||
}); | ||
|
||
var fs = require('fs'); | ||
|
||
var babelrc = fs.readFileSync('./.babelrc'); | ||
var config; | ||
|
||
try { | ||
config = JSON.parse(babelrc); | ||
} catch (err) { | ||
console.error('==> ERROR: Error parsing your .babelrc.'); | ||
console.error(err); | ||
} | ||
|
||
require('babel/register')(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
var WebpackDevServer = require('webpack-dev-server'), | ||
webpack = require('webpack'), | ||
config = require('./dev.config'), | ||
host = process.env.HOST || 'localhost', | ||
port = parseInt(process.env.PORT) + 1 || 3001, | ||
serverOptions = { | ||
contentBase: 'http://' + host + ':' + port, | ||
quiet: true, | ||
noInfo: true, | ||
hot: true, | ||
inline: true, | ||
lazy: false, | ||
publicPath: config.output.publicPath, | ||
headers: {"Access-Control-Allow-Origin": "*"}, | ||
stats: {colors: true} | ||
}, | ||
webpackDevServer = new WebpackDevServer(webpack(config), serverOptions); | ||
var Express = require('express'); | ||
var webpack = require('webpack'); | ||
|
||
webpackDevServer.listen(port, host, function() { | ||
console.info('==> 🚧 Webpack development server listening on %s:%s', host, port); | ||
var config = require('../src/config'); | ||
var webpackConfig = require('./dev.config'); | ||
var compiler = webpack(webpackConfig); | ||
|
||
var host = process.env.HOST || 'localhost'; | ||
var port = parseInt(config.port, 10) + 1 || 3001; | ||
var serverOptions = { | ||
contentBase: 'http://' + host + ':' + port, | ||
quiet: true, | ||
noInfo: true, | ||
hot: true, | ||
inline: true, | ||
lazy: false, | ||
publicPath: webpackConfig.output.publicPath, | ||
headers: {'Access-Control-Allow-Origin': '*'}, | ||
stats: {colors: true} | ||
}; | ||
|
||
var app = new Express(); | ||
|
||
app.use(require('webpack-dev-middleware')(compiler, serverOptions)); | ||
app.use(require('webpack-hot-middleware')(compiler)); | ||
|
||
app.listen(port, function onAppListening(err) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
console.info('==> 🚧 Webpack development server listening on port %s', port); | ||
} | ||
}); |