-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何变更一个非相关文件但引发 webpack 重新构建 #7
Labels
Comments
webpack/webpack-dev-server#34 这里曾经有过相关讨论 this.addDependency(filePath) 来把该文件纳入 webpack 的依赖收集中,并且热更新什么的都运作完美。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在调试环境中我们通常会有如下需求:
这个场景就比如小程序中的
[page].json
以往我们的做法比较绕,大致可以归结为:
嗯,没毛病
但是这一次看 webpack watch 实现,让我对 watch 整体实现有了非常全面的了解。
如果仔细读过文章,可以知道 webpack 的监听是发生在 compile 之后的。
另外 webpack 监听的内容发生变更终将引发新的 compile 过程,这个过程可以在文章 webpack watch 实现 的手稿笔记中,查看蓝色部分的回调链路。
带着这样的思路,我给出了一个假设:
比较庆幸的是在读 watch 机制的时候,大致看了下 webpack 的事件机制。 这一块后续必须要研读,非常具有借鉴意义。
在时间机制中有一个事件是
after-compile
就琢磨着,我就在这个时机修改下是否就可以了呢?wala
于是就有了这个插件
extra-watch-webpack-plugin
插件实现非常简单,可以自行前往如上链接查看源码。
接下来大概说下如何使用这个插件吧
安装
可选参数
files
:string
orarray
, defualt[]
, attach extra files to webpack's watch systemdirs
:string
orarray
, defualt[]
, attach extra dirs to webpack's watch systemUsage
The text was updated successfully, but these errors were encountered: