feat(core): warn users about hand-modifying generated files (#6419)

* feat(core): warn users about hand-modifying generated files

* Better folder name
This commit is contained in:
Joshua Chen 2022-01-20 21:41:59 +08:00 committed by GitHub
parent d133910cb2
commit 65c2fc200a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -304,13 +304,27 @@ export async function load(
context.siteConfig.themeConfig = themeConfigTranslated;
handleDuplicateRoutes(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
const genWarning = generate(
generatedFilesDir,
'DONT-EDIT-THIS-FOLDER',
`This folder stores temp files that Docusaurus' client bundler accesses.
DO NOT hand-modify files in this folder because they will be overwritten in the
next build. You can clear all build artifacts (including this folder) with the
\`docusaurus clear\` command.
`,
);
// Site config must be generated after plugins
// We want the generated config to have been normalized by the plugins!
const genSiteConfig = generate(
generatedFilesDir,
DEFAULT_CONFIG_FILE_NAME,
`export default ${JSON.stringify(siteConfig, null, 2)};`,
`/*
AUTOGENERATED - DON'T EDIT
Your edits in this file will be overwritten in the next build!
Modify the docusaurus.config.js file at your site's root instead.
*/
export default ${JSON.stringify(siteConfig, null, 2)};`,
);
plugins.push(createBootstrapPlugin({siteConfig}));
@ -402,6 +416,7 @@ ${Object.keys(registry)
);
await Promise.all([
genWarning,
genClientModules,
genSiteConfig,
genRegistry,