leecade / koa-webpack-middleware

webpack dev&hot middleware for koa2
214 stars 29 forks source link

Combine Setup for Efficiency #27

Open shellscape opened 7 years ago

shellscape commented 7 years ago

I'd like to request refactoring to combine all of the setup between dev-middleware and hot-middleware. I've never seen an example where they aren't app.use'd in succession, and given that their options are distinct this should be a trivial refactor:

import packWare from 'koa-webpack-middleware';

app.use(packWare({
  dev: // dev options,
  hot: // hot options,
  compiler: // optional webpack instance,
  config: // optional webpack config. should look for webpack.config.js in root by default
]);

webpack can be imported via a peerDependency entry for the webpack module in package.json, or provided as part of the config of the middleware. This negates the need to set that portion up manually for each use of koa-webpack-middleware.

If you're open to this change, I'll put together a pull request. I'd also be happy to provide an example for Vue.js.

shellscape commented 7 years ago

Ended up releasing https://github.com/shellscape/koa-webpack. I guess koa-webpack-middleware isn't maintained or watched by the author anymore.

axe312ger commented 7 years ago

@shellscape thank you so much! We should move a link to your repo into the webpack documentation.

shellscape commented 7 years ago

@axe312ger you're welcome! I'd be all for that.

axe312ger commented 7 years ago

@shellscape just found this -> https://github.com/webpack/webpack-dev-middleware/issues/148