Webpack vs webpack-dev-server vs webpack-dev-middleware vs webpack-hot-middleware vs etc

后端 未结 2 931
小蘑菇
小蘑菇 2020-12-22 17:24

I\'m starting working with webpack with a node/express environment developing a ReactJS server side rendered application with re

相关标签:
2条回答
  • 2020-12-22 17:44

    As of update in 2018 and considering the webpack-dev-server note on its official GitHub page:

    Project in Maintenance Please note that webpack-dev-server is presently in a maintenance-only mode and will not be accepting any additional features in the near term. Most new feature requests can be accomplished with Express middleware; please look into using the before and after hooks in the documentation.

    What would be the natural choice to build a webpack HMR ?

    0 讨论(0)
  • 2020-12-22 17:50

    webpack

    As you've described, Webpack is a module bundler, it bundles various module formats primarily so they can be run in a browser. It offers both a CLI and Node API.

    webpack-dev-middleware

    Webpack Dev Middleware is middleware which can be mounted in an express server to serve the latest compilation of your bundle during development. This uses webpack's Node API in watch mode and instead of outputting to the file system it outputs to memory.

    For comparison, you might use something like express.static instead of this middleware in production.

    webpack-dev-server

    Webpack Dev Server is itself an express server which uses webpack-dev-middleware to serve the latest bundle and additionally handles hot module replacement (HMR) requests for live module updates in the client.

    webpack-hot-middleware

    Webpack Hot Middleware is an alternative to webpack-dev-server but instead of starting a server itself it allows you to mount it in an existing / custom express server alongside webpack-dev-middleware.

    Also...

    webpack-hot-server-middleware

    Just to confuse things even more, there's also Webpack Hot Server Middleware which is designed to be used alongside webpack-dev-middleware and webpack-hot-middleware to handle hot module replacement of server rendered apps.

    0 讨论(0)
提交回复
热议问题