mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
perf(v2): improve dev build time by not overwriting file if possible (#2089)
* perf(v2): improve sequential build time by not overwriting file if possible * minor improvement * docs
This commit is contained in:
parent
ff4851982c
commit
32c9d07b90
2 changed files with 14 additions and 1 deletions
|
@ -27,7 +27,19 @@ export async function generate(
|
|||
return;
|
||||
}
|
||||
|
||||
const lastHash = fileHash.get(filepath);
|
||||
let lastHash = fileHash.get(filepath);
|
||||
|
||||
// If file already exist but its not in runtime cache hash yet,
|
||||
// we try to calculate the content hash and then compare
|
||||
// This is to avoid unnecessary overwrite and we can reuse old file
|
||||
if (!lastHash && fs.existsSync(filepath)) {
|
||||
const lastContent = await fs.readFile(filepath, 'utf8');
|
||||
lastHash = createHash('md5')
|
||||
.update(lastContent)
|
||||
.digest('hex');
|
||||
fileHash.set(filepath, lastHash);
|
||||
}
|
||||
|
||||
const currentHash = createHash('md5')
|
||||
.update(content)
|
||||
.digest('hex');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue