mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
Remove content database from the static build
This commit is contained in:
parent
1e21aeee13
commit
c503cd602b
1 changed files with 15 additions and 1 deletions
|
@ -61,7 +61,21 @@ export function fileURLIntegration(): AstroIntegration {
|
|||
config = _config;
|
||||
},
|
||||
async 'astro:build:done'() {
|
||||
if (config.output !== 'static') {
|
||||
if (config.output === 'static') {
|
||||
// Delete the files since they are only used for the build process.
|
||||
const unlinks: Promise<unknown>[] = [];
|
||||
for (const fileName of fileNames) {
|
||||
const url = new URL(fileName, config.outDir);
|
||||
unlinks.push(fs.promises.unlink(url));
|
||||
}
|
||||
await Promise.all(unlinks);
|
||||
const assetDir = new URL(config.build.assets, config.outDir);
|
||||
const assetFiles = await fs.promises.readdir(assetDir);
|
||||
if(!assetFiles.length) {
|
||||
// Directory is empty, delete it.
|
||||
await fs.promises.rmdir(assetDir);
|
||||
}
|
||||
} else {
|
||||
// Move files back over to the dist output path
|
||||
const moves: Promise<unknown>[] = [];
|
||||
for (const fileName of fileNames) {
|
||||
|
|
Loading…
Add table
Reference in a new issue