Giter Site home page Giter Site logo

Comments (4)

gwuhaolin avatar gwuhaolin commented on May 26, 2024

自动刷新网页由两大步骤实现:

  1. webpack 开启监听模式时会监听文件变化事件,在文件发生变化时重新构建,输出新的结果。也就是说webpack 的职责是监听文件变化和重新构建。
  2. webpack-dev-server 在收到webpack发送给它的文件变化消息后,通过websocket向网页发指令,运行在网页中的代理客户端收到指令后刷新网页。也就是webpack-dev-server的职责是去控制浏览器。

详情见 4-5使用自动刷新

from dive-into-webpack.

gaoguoxin avatar gaoguoxin commented on May 26, 2024

hey,你书里面说的是webpack原生支持网页自动刷新,而不是通过webpack-dev-server,按照你的解释,webpack是不能原生支持网页自动刷新的,是必须通过webpack-dev-server的,无论是通过模块热加载还是通过websocket,都是借助了webpack-dev-server,所以我觉得书里面说的webpack原生只会网页自动刷新是错误的。

from dive-into-webpack.

zshawk1992 avatar zshawk1992 commented on May 26, 2024

@gaoguoxin 作者没有解释错误,webpack只负责监听文件,webpack-dev-server负责刷新

from dive-into-webpack.

biley avatar biley commented on May 26, 2024

我也是看到这个问题来找 issue 的,这是 1-6 中的内容。其中原文为:

实际开发中你可能会需要:

  1. 提供 HTTP 服务而不是使用本地文件预览;
  2. 监听文件的变化并自动刷新网页,做到实时预览;
  3. 支持 Source Map,以方便调试。

以及

Webpack 原生支持上述第2、3点内容,再结合官方提供的开发工具 DevServer 也可以很方便地做到第1点。

其中 webpack 可以原生支持第二点是有误的。

from dive-into-webpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.