Skip to content

Commit

Permalink
refactor(preset): only watch local deps change in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Apr 19, 2020
1 parent 3dde561 commit bcf515d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/preset-dumi/src/transformer/demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ export default (
};

// watch deps change
if (fileWatchers[resolvePath]) {
fileWatchers[resolvePath].close();
if (process.env.NODE_ENV === 'development') {
if (fileWatchers[resolvePath]) {
fileWatchers[resolvePath].close();
}

fileWatchers[resolvePath] = fs.watch(resolvePath, () => {
// trigger parent file change to update frontmatter when dep file change
fs.writeFileSync(fileAbsPath, fs.readFileSync(fileAbsPath));
});
}

fileWatchers[resolvePath] = fs.watch(resolvePath, () => {
// trigger parent file change to update frontmatter when dep file change
fs.writeFileSync(fileAbsPath, fs.readFileSync(fileAbsPath));
});
}
}
},
Expand Down

0 comments on commit bcf515d

Please sign in to comment.