Skip to content

Commit

Permalink
fix(v2): clean generated manifest from previous build so we dont use …
Browse files Browse the repository at this point in the history
…the wrong one (#2060)
  • Loading branch information
endiliey authored and yangshun committed Nov 27, 2019
1 parent bd5bdb9 commit 5adb583
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/docusaurus/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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[],
});
Expand Down Expand Up @@ -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]);

Expand Down

0 comments on commit 5adb583

Please sign in to comment.