Fix Webpack default entry issue: webpackConfig.entry.main.unshift is not a function

Closes #56
This commit is contained in:
Andrei Tserakhau
2016-04-29 14:05:50 +03:00
parent 7b53e4aa55
commit 754e32b604

View File

@@ -40,7 +40,11 @@ export function createWebpackDevServer(callback: CreateDevServerCallback, option
// Build the final Webpack config based on supplied options // Build the final Webpack config based on supplied options
if (enableHotModuleReplacement) { if (enableHotModuleReplacement) {
// TODO: Stop assuming there's an entry point called 'main' // TODO: Stop assuming there's an entry point called 'main'
if (typeof webpackConfig.entry['main'] === 'string') {
webpackConfig.entry['main'] = ['webpack-hot-middleware/client', webpackConfig.entry['main']];
} else {
webpackConfig.entry['main'].unshift('webpack-hot-middleware/client'); webpackConfig.entry['main'].unshift('webpack-hot-middleware/client');
}
webpackConfig.plugins.push( webpackConfig.plugins.push(
new webpack.HotModuleReplacementPlugin() new webpack.HotModuleReplacementPlugin()
); );