mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 18:27:56 +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;
|
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')
|
const currentHash = createHash('md5')
|
||||||
.update(content)
|
.update(content)
|
||||||
.digest('hex');
|
.digest('hex');
|
||||||
|
|
|
@ -183,6 +183,7 @@ For example, if you are in `doc2.md` and you want to reference `doc1.md` and `fo
|
||||||
|
|
||||||
```md
|
```md
|
||||||
I am referencing a [document](doc1.md). Reference to another [document in a folder](folder/doc3.md)
|
I am referencing a [document](doc1.md). Reference to another [document in a folder](folder/doc3.md)
|
||||||
|
[Relative document](../doc2.md) referencing works as well.
|
||||||
```
|
```
|
||||||
|
|
||||||
One benefit of this approach is that the links to external files will still work if you are viewing the file on GitHub.
|
One benefit of this approach is that the links to external files will still work if you are viewing the file on GitHub.
|
||||||
|
|
Loading…
Add table
Reference in a new issue