Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

希望在example中能添加一个热更新的最佳案例 #99

Open
chenmingjia opened this issue Sep 12, 2018 · 4 comments
Open

希望在example中能添加一个热更新的最佳案例 #99

chenmingjia opened this issue Sep 12, 2018 · 4 comments

Comments

@chenmingjia
Copy link
Contributor

react-hot-loader 已经生效,但是还是有些地方不方便
实际在开发同构渲染项目,感觉热更新还是有些不好使,开发效率很容易降低,具体体现在:

  1. css响应 场景示例是:在example中的simple项目 run dev 运行以后,对下面代码增加新样式,会发现不起作用,得再次重新构建,才能生效
 <h1 className="title">Script22</h1>
 <p  /* 新增新的class  */>
      Scripting page template in `/client/script/index.jsx`, visit via url
      `/script`
 </p>
  /* 
      N 行已有代码,略
  */

似乎对服务端已渲染后节点,添加className, 客户端会仍然选择服务端渲染顺序的样式

  1. 开启多页应用后 react-hot-loader 就不起作用了,希望能在antd-admin 增加类似的配置.....
@njugray
Copy link
Contributor

njugray commented Feb 12, 2019

似乎对服务端已渲染后节点,添加className, 客户端会仍然选择服务端渲染顺序的样式

className 修改后,热更新肯定是生效了的,样式有关的热更新问题是 css 无法热替换导致的,这是 使用了extract-text-plugin 后导致的 相关issue: webpack-contrib/extract-text-webpack-plugin#30

可以考虑升级到 mini-css-extract-plugin,后者有提供HMR的计划 webpack-contrib/mini-css-extract-plugin#34

@ahungrynoob
Copy link
Contributor

dev模式下:css-loader + style-loader
build时再extract-text?
可行性高吗

@njugray
Copy link
Contributor

njugray commented Feb 18, 2019

增加配置参数,判断是否使用 extract-text-plugin,这个实现起来没什么难度。

但是会额外提高理解成本,并且页面模板也需要区分 dev,判断是否 link css文件,这部分是要用户自己修改的。dev和线上相当于是两套逻辑,也会有不可预知的风险存在

@ahungrynoob
Copy link
Contributor

嗯。所以next.js自己封装了

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants