Move COMPONENT_API to src/generated

This commit is contained in:
venashial
2022-03-30 14:05:15 -07:00
parent 425c8cd1d3
commit cbc85ca98f
6 changed files with 17 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ export default function sveld() {
}
},
// This generates a `COMPONENT_API.json` with sveld in the `/_app` folder on build, which is used by the docs about components (only when built statically)
async generateBundle(options, bundle) {
async buildStart() {
const output = {};
const componentFiles = await fs.readdir(path.resolve('./src/lib/components'))
@@ -31,11 +31,13 @@ export default function sveld() {
output[fileName] = await parseRaw(raw, filePath)
}
this.emitFile({
type: 'asset',
fileName: 'COMPONENT_API.json',
source: JSON.stringify(output),
})
try {
await fs.mkdir(path.resolve('./src/generated'))
} catch {
// Do nothing, directory already exists
}
await fs.writeFile(path.resolve('./src/generated/COMPONENT_API.json'), JSON.stringify(output))
},
}
}