From 65c2fc200a4e86fe74f9d6af1b444038cdb893fa Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Thu, 20 Jan 2022 21:41:59 +0800 Subject: [PATCH] feat(core): warn users about hand-modifying generated files (#6419) * feat(core): warn users about hand-modifying generated files * Better folder name --- packages/docusaurus/src/server/index.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus/src/server/index.ts b/packages/docusaurus/src/server/index.ts index 9e5618106d..5142fbc59f 100644 --- a/packages/docusaurus/src/server/index.ts +++ b/packages/docusaurus/src/server/index.ts @@ -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,