feat(docs): always re-build api references in build mode (#298)

Before the API References did not get re-build when running
`npm run docs:build` which caused some confusion.

**Explanation**
One can check if `docusaurus` runs in `build` mode using the
`NODE_ENV` environment variable which will be set to `production`
if that's the case. If the variable is set we ignore previously build
files and re-build them including the `api.json`.

Closes: #294
This commit is contained in:
Tan to the Dashi
2023-02-11 08:38:59 +01:00
committed by GitHub
parent 7c6905d72c
commit 27a4d96593

View File

@@ -16,7 +16,7 @@ module.exports = () => ({
name: 'docusaurus-typedoc-plugin',
async loadContent() {
const dir = './src/generated';
if (fs.existsSync(dir)) {
if (fs.existsSync(dir) && process.env.NODE_ENV !== 'production') {
const api = JSON.parse(
await fs.promises.readFile(`${dir}/api.json`, 'utf8'),
);