Skip to content

Commit

Permalink
feat(mini-runner): 优化 watch
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Jan 7, 2020
1 parent 0b2e882 commit 4c60cd6
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 @@ -176,7 +176,8 @@ export default class MiniPlugin {
compiler.hooks.watchRun.tapAsync(
PLUGIN_NAME,
this.tryAsync(async (compiler: webpack.Compiler) => {
this.run(compiler)
const changedFile = this.getChangedFiles(compiler)
await this.watchRun(compiler, changedFile)
})
)

Expand All @@ -200,6 +201,13 @@ export default class MiniPlugin {
new TaroNormalModulesPlugin().apply(compiler)
}

getChangedFiles (compiler) {
const { watchFileSystem } = compiler;
const watcher = watchFileSystem.watcher || watchFileSystem.wfs.watcher;

return Object.keys(watcher.mtimes)
}

getAppEntry (compiler) {
if (this.options.appEntry) {
return this.options.appEntry
Expand Down Expand Up @@ -673,6 +681,10 @@ export default class MiniPlugin {
this.transferFileContent(compiler)
}

watchRun (compiler: webpack.Compiler, changedFile: string[]) {

}

getTargetFilePath (filePath, targetExtname) {
const extname = path.extname(filePath)
if (extname) {
Expand Down

0 comments on commit 4c60cd6

Please sign in to comment.