Skip to content

Commit

Permalink
Production section explains how to get rid out of HMR error and warn …
Browse files Browse the repository at this point in the history
…logs after production compilation.

It contains plain recommendations for production bundling.

Fix #649
Fix typos after review.
  • Loading branch information
AlexanderTserkovniy committed Jan 17, 2017
1 parent a6f9bd3 commit 0706631
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions content/guides/hmr-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ contributors:
- jhnns
- sararubin
- aiduryagin
- AlexanderTserkovniy
---

As explained in detail on the [concept page](/concepts/hot-module-replacement), Hot Module Replacement (HMR) exchanges, adds, or removes modules while an application is running without a page reload.
Expand Down Expand Up @@ -296,3 +297,24 @@ dev-server.js:27 [HMR] App is up to date.

Note that HMR specifies the paths of the updated modules.
That's because we're using `NamedModulesPlugin`.

### Production

Minimal steps in order to get rid of HMR on production. As webpack sets `NODE_ENV` for working files only, we need to specify it before webpack for production is invoked.

Add in `package.json` next script:
```json
"scripts": {
"build": "NODE_ENV=production webpack -p"
}
```

Add in webpack config next code:
```js
if (process.env.NODE_ENV === 'production') {
module.exports.plugins = []; // remove Hot Module Replacement from plugins
module.exports.entry = resolve(__dirname, 'index.js'); // remove Hot Module Replacement from entry
}
```

Enjoy empty from errors console.

0 comments on commit 0706631

Please sign in to comment.