Skip to content

Commit

Permalink
fix(mini-runner): 修复组件 watch 时改动不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 31, 2019
1 parent 801bb80 commit 8cfd5bb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,19 @@ export default class MiniPlugin {
this.isWatch = true
if (REG_SCRIPTS.test(changedFile)) {
this.changedFile = changedFile
const { type, obj } = this.getChangedFileInfo(changedFile)
let { type, obj } = this.getChangedFileInfo(changedFile)
if (!type) {
const code = fs.readFileSync(changedFile).toString()
const isTaroComponentRes = isFileToBeTaroComponent(code, changedFile, this.options.buildAdapter)
if (isTaroComponentRes.isTaroComponent) {
type = PARSE_AST_TYPE.COMPONENT
obj = {
name: changedFile.replace(this.sourceDir, '').replace(path.extname(changedFile), ''),
path: changedFile,
isNative: this.isNativePageOrComponent(this.getTemplatePath(changedFile), code)
}
}
}
this.changedFileType = type
if (this.changedFileType === PARSE_AST_TYPE.ENTRY
|| this.changedFileType === PARSE_AST_TYPE.PAGE
Expand Down

0 comments on commit 8cfd5bb

Please sign in to comment.