Skip to content

Commit

Permalink
Fixed HMR work in development mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
BiosBoy committed Jun 13, 2019
1 parent 850a8e6 commit adfadef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Webpack4 - React16.7 Templater App


# 2.1.2
* Fixed HMR work in development mode.

# 2.1.1
* Update UjlifyJS plugin correspond to its internal update.
* Improved distinguish between prod and dev version running via Hot Module Replacement.
Expand Down
4 changes: 2 additions & 2 deletions server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const bundler = webpack(webpackConfig);
// ========================================================
const devMiddlewareOptions = {
publicPath: webpackConfig.output.publicPath,
hot: globals.__DEV__ ? true : false,
hot: __DEV__ ? true : false,
headers: { 'Access-Control-Allow-Origin': '*' }
};

Expand All @@ -24,7 +24,7 @@ const devMiddlewareOptions = {
// ========================================================
const webpackMiddleware = [webpackDevMiddleware(bundler, devMiddlewareOptions)];

if (globals.__DEV__) {
if (__DEV__) {
webpackMiddleware.push(webpackHotMiddleware(bundler));
}

Expand Down
12 changes: 6 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ const createConfig = () => {
// ------------------------------------
// Entry Points
// ------------------------------------
const appEntryPoint = ['babel-polyfill', path.resolve(__dirname, 'src/index.js')];
const appEnterPrefixPlugins = ['babel-polyfill'];
const appPath = path.resolve(__dirname, 'src/index.js');
const appEntryPoint = [...appEnterPrefixPlugins, appPath];

if (__DEV__) {
const HMRPath = 'webpack-hot-middleware/client?path=/__webpack_hmr';

appEntryPoint[1].concat(HMRPath);
}
webpackConfig.entry = {
app: __DEV__ ? appEntryPoint.concat('webpack-hot-middleware/client?path=/__webpack_hmr') : appEntryPoint
};

webpackConfig.entry = {
app: appEntryPoint
Expand Down

0 comments on commit adfadef

Please sign in to comment.