webpack-contrib / webpack-hot-middleware

Webpack hot reloading you can attach to your own server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unclear which order middleware should be registered

ORESoftware opened this issue · comments

Given the docs (the readme.md file) it's unclear what order the middleware should be registered. Here is what I have:

  const webpack = require('webpack');
  const WebpackDashboardPlugin = require('webpack-dashboard/plugin');
  const config = require('./webpack.config.dev');
  /* eslint-enable import/no-extraneous-dependencies, global-require */

  const compiler = webpack(config);
  app.use(require("webpack-hot-middleware")(compiler));
  compiler.apply(new WebpackDashboardPlugin());
  app.use(require('webpack-dev-middleware')(compiler, { publicPath: config.output.publicPath }));

however, it could just as well be this instead:

  const webpack = require('webpack');
  const WebpackDashboardPlugin = require('webpack-dashboard/plugin');
  const config = require('./webpack.config.dev');
  /* eslint-enable import/no-extraneous-dependencies, global-require */

  const compiler = webpack(config);
  compiler.apply(new WebpackDashboardPlugin());  
  app.use(require('webpack-dev-middleware')(compiler, { publicPath: config.output.publicPath }));
  app.use(require("webpack-hot-middleware")(compiler));

does the order matter? thanks

The middleware don't listen on the same paths, so it doesn't matter which order they're applied in.

The example in the READM shows the recommended approach, but if the other way is working for you then that's fine.