webpack-contrib / webpack-hot-client

webpack HMR Client
MIT License
121 stars 45 forks source link

Webpack-Hot-Client not working with entrypoints at different routes #90

Closed Sawtaytoes closed 6 years ago

Sawtaytoes commented 6 years ago

Expected Behavior

Webpack-Hot-Client runs on all entrypoints on all routes.

Actual Behavior

Webpack-Hot-Client only runs on routes that reference back to / and not any other routes using differing entrypoints.

Code

Webpack Entrypoint Configs

Client

  entry: {
    app: [
      'react-hot-loader/patch',
      '/app/entrypoints/client.js',
    ],
    tests: [
      'react-hot-loader/patch',
      '/app/entrypoints/clientTests.js',
    ],
  },

Server

  entry: {
    app: '/app/entrypoints/server.js',
    tests: '/app/entrypoints/serverTests.js',
  },

Express Config

.get('/tests', '/bundles/serverTests.js')
.all('*', '/bundles/server.js')

HTML

/

<script defer src="/app.client.js" />

/tests

<script defer src="/tests.client.js" />

How Do We Reproduce?

Setup a path in Express on / to run one entrypoint and set another path on /something to run a different entrypoint. Only the entrypoint at / will get Webpack-Hot-Client.

shellscape commented 6 years ago

README has what you're looking for. https://github.com/webpack-contrib/webpack-hot-client#allentries. If that doesn't do it, please triage in your scenario and post a cause of the issue, and we'll reopen.

FWIW, this module has absolutely nothing to do with Express, so routing, etc wouldn't matter. This is a webpack configuration issue.

Sawtaytoes commented 6 years ago

That's the solution. I must've not understood it before, but now that I have this issue, the description makes sense.

Might be better to say something like:

By default, webpack-hot-client only looks at the first entry. If you want all entry keys to be configured for the webpack compiler, set this setting and autoConfigure to true.