Skip to content
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

可能会碰到的问题 #3

Open
wangly19 opened this issue Apr 5, 2020 · 5 comments
Open

可能会碰到的问题 #3

wangly19 opened this issue Apr 5, 2020 · 5 comments

Comments

@wangly19
Copy link

wangly19 commented Apr 5, 2020

Possible problems

  1. When you modify the template, the source slot does not seem to be hot updated?
  2. When your html code code is too long, it may cause the hidden code to be lost
    tips: The reason may be caused by the is-fixed decoration class. You can add the following code to vuepress to inherit the position pointed by the unknown.
.demo-block .demo-block-control.is-fixed {
   position: initial! important;
   bottom: 0! important;
   width: 100%! important;
}
@wangly19
Copy link
Author

wangly19 commented Apr 5, 2020

可能会出现的问题

  1. 当你修改模板,source插槽好像没有被热更新?
  2. 当你的html code代码过长,可能会导致隐藏代码丢失
    tips: 原因可能是由is-fixed装饰类导致的,可以在vuepress中添加以下代码,将这个未知指向的position继承,!important非必须的。
.demo-block .demo-block-control.is-fixed {
  position: initial !important;
  bottom: 0 !important;
  width: 100% !important;
}

@rat1991
Copy link

rat1991 commented Jun 4, 2020

关于热更新的问题,有解决方法吗

@busyrat
Copy link
Owner

busyrat commented Feb 24, 2021

关于热更新的问题,有解决方法吗

vuejs/vuepress#2392 (comment)

可以参考这个~

@soluteli
Copy link

关于热更新的问题,有解决方法吗
vuepress 默认不监听 ctx.tempPath,改个文件生成地址就可以了

@warpcgd
Copy link

warpcgd commented May 27, 2021

关于热更新的问题,有解决方法吗
vuepress 默认不监听 ctx.tempPath,改个文件生成地址就可以了

目前改了ctx.tempPath也不能解决热更的问题,vue-demo是期望@vuepress/register-components来注册demo组件,

然而@vuepress/register-components是在enhanceAppFiles注册特定文件夹里面vue内容,热更新时,不会重新执行enhanceAppFiles


解决思路 1:

看了一圈vuepress热更的问题,目前vuepress v1.8.x版本能监听到config.js的改变并进行重新构建,如果在每次解析markdown的时候,能输出组件到temp,同时更新config.js的修改时间,就能触发@vuepress/register-components的重新注册

当然,这种方法会导致vuepress每次更新都重新构建,而且首次构建的时候会构建多次,但是在开发阶段这种损耗还是能接受的,生产阶段则无需使用热更

vuepressupdated钩子好像没用,不然应该可以解决构建多次的问题

https://github.com/busyrat/vuepress-plugins/blob/master/packages/vue-demo/containers.js#L32 后执行triggerConfigHotFix(ctx) 就能热更了

const triggerConfigHotFix = async (ctx)  => {
  const fs = require('fs')
  const path = require('path')
  const fileDir = path.resolve(ctx.sourceDir, './.vuepress/config.js')
  await fs.utimesSync(fileDir, new Date(),new Date())
}

解决思路 2:

vuepress官网有一个extraWatchFiles的配置,我们可以增加需要监听temp文件夹下的vue文件,但是这个不能监听文件夹的变化,目前vue-demo每次更新会新增一个vue文件,这可能需要修改源码来满足

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

No branches or pull requests

5 participants