diff --git a/README.md b/README.md index 09a01b6..00e96ac 100644 --- a/README.md +++ b/README.md @@ -130,16 +130,7 @@ module.exports = merge(sharedConfig, ...) If you need to change your configuration manually: -1. set the public URL used to load `webpack-dev-server` assets - ```js - { - output: { - publicPath: 'http://localhost:8080' - } - } - ``` - -2. add `react-hot-loader/babel` to your `babel-loader` rules: +1. add `react-hot-loader/babel` to your `babel-loader` rules: ```javascript { module: { @@ -159,7 +150,7 @@ If you need to change your configuration manually: } ``` -3. prepend `react-hot-loader/patch` to your entries: +2. prepend `react-hot-loader/patch` to your entries: ```javascript { entry: @@ -168,7 +159,7 @@ If you need to change your configuration manually: } ``` -4. you now need to use `webpack-dev-server` (in place of `webpack` or `webpack-watcher`). Make sure the following line is in your development.rb: +3. you now need to use `webpack-dev-server` (in place of `webpack` or `webpack-watcher`). Make sure the following line is in your development.rb: ```ruby config.x.webpacker[:dev_server_host] = 'http://localhost:8080/' ``` @@ -177,7 +168,7 @@ and start `webpack-dev-server` in hot replacement mode: ./bin/webpack-dev-server --hot ``` -5. finally opt in to HMR from your pack files: +4. finally opt in to HMR from your pack files: ```es6 import SomeRootReactComponent from 'components/some-root-react-component' import WebpackerReact from 'webpacker-react/hmr' @@ -188,6 +179,8 @@ and start `webpack-dev-server` in hot replacement mode: WebpackerReact.renderOnHMR(SomeRootReactComponent) ) ``` +You also need to ensure that `output.publicPath` are correctly set. This should be already handled by Webpacker. + ## Development To work on this gem locally, you first need to clone and setup [the example application](https://github.com/renchap/webpacker-react-example). diff --git a/javascript/webpacker_react-npm-module/src/configure-hot-module-replacement.js b/javascript/webpacker_react-npm-module/src/configure-hot-module-replacement.js index 7b3e339..fdb1825 100644 --- a/javascript/webpacker_react-npm-module/src/configure-hot-module-replacement.js +++ b/javascript/webpacker_react-npm-module/src/configure-hot-module-replacement.js @@ -2,14 +2,9 @@ import webpack from 'webpack' import merge from 'webpack-merge' function configureHotModuleReplacement(originalConfig) { - const webpackDevServerAddr = process.env.WEBPACK_DEV_SERVER_ADDR || 'http://localhost:8080/' const config = merge( originalConfig, { - output: { - // needed for HMR to know where to load the hot update chunks - publicPath: webpackDevServerAddr - }, plugins: [ new webpack.NamedModulesPlugin() ] diff --git a/javascript/webpacker_react-npm-module/yarn.lock b/javascript/webpacker_react-npm-module/yarn.lock index 5c41ee9..fcd2490 100644 --- a/javascript/webpacker_react-npm-module/yarn.lock +++ b/javascript/webpacker_react-npm-module/yarn.lock @@ -1573,7 +1573,7 @@ lodash.cond@^4.3.0: version "4.5.2" resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" -lodash@^4.0.0, lodash@^4.2.0, lodash@^4.3.0, "lodash@~> 4": +lodash@^4.0.0, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -2010,13 +2010,7 @@ restore-cursor@^1.0.1: exit-hook "^1.0.0" onetime "^1.0.0" -rimraf@2, rimraf@^2.2.8: - version "2.6.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" - dependencies: - glob "^7.0.5" - -rimraf@~2.5.1, rimraf@~2.5.4: +rimraf@2, rimraf@^2.2.8, rimraf@~2.5.1, rimraf@~2.5.4: version "2.5.4" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" dependencies: