mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 10:48:05 +02:00
fix(v2): clean generated manifest from previous build so we dont use the wrong one (#2060)
This commit is contained in:
parent
bd5bdb91f7
commit
5adb58380c
1 changed files with 16 additions and 1 deletions
|
@ -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]);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue