From 5adb58380c1bc0b06c572beec928e11b1ceebcc0 Mon Sep 17 00:00:00 2001 From: Endi Date: Wed, 27 Nov 2019 23:13:12 +0700 Subject: [PATCH] fix(v2): clean generated manifest from previous build so we dont use the wrong one (#2060) --- packages/docusaurus/src/commands/build.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus/src/commands/build.ts b/packages/docusaurus/src/commands/build.ts index 97b476ba2e..4ed2e9b44b 100644 --- a/packages/docusaurus/src/commands/build.ts +++ b/packages/docusaurus/src/commands/build.ts @@ -57,6 +57,10 @@ export async function build( // Apply user webpack config. const {outDir, generatedFilesDir, plugins} = props; + const clientManifestPath = path.join( + generatedFilesDir, + 'client-manifest.json', + ); let clientConfig: Configuration = merge(createClientConfig(props), { plugins: [ // Remove/clean build folders before building bundles. @@ -65,7 +69,7 @@ export async function build( cliOptions.bundleAnalyzer && new BundleAnalyzerPlugin(), // Generate client manifests file that will be used for server bundle new ReactLoadableSSRAddon({ - filename: path.join(generatedFilesDir, 'client-manifest.json'), + filename: clientManifestPath, }), ].filter(Boolean) as Plugin[], }); @@ -104,6 +108,17 @@ export async function build( ); }); + // Make sure generated client-manifest and chunk-map is cleaned first so we don't reuse the one from prevs build + const chunkManifestPath = path.join(generatedFilesDir, 'chunk-map.json'); + await Promise.all( + [clientManifestPath, chunkManifestPath].map(async manifestPath => { + const manifestExist = await fs.pathExists(manifestPath); + if (manifestExist) { + await fs.unlink(manifestPath); + } + }), + ); + // Run webpack to build JS bundle (client) and static html files (server). await compile([clientConfig, serverConfig]);