Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v2): clean generated manifest from previous build so we dont use the wrong one #2060

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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