@@ -2,6 +2,7 @@ import { defineConfig } from 'astro/config';
22import react from "@astrojs/react" ;
33import starlight from "@astrojs/starlight" ;
44import starlightTypeDoc , { typeDocSidebarGroup } from 'starlight-typedoc' ;
5+ import fs from 'node:fs'
56
67import sitemap from '@astrojs/sitemap' ;
78
@@ -47,20 +48,23 @@ export default defineConfig({
4748 './src/layouts/colorvars.css' ,
4849 ] ,
4950 plugins : [
50- // Generate the documentation.
51- starlightTypeDoc ( {
52- entryPoints : [ './fabric.js/fabric.ts' ] ,
53- tsconfig : './fabric.js/typedoc.config.json' ,
54- typeDoc : {
55- plugin : [ 'typedoc-plugin-no-inherit' ] ,
56- readme : 'none' ,
57- gitRemote : 'https://github.com/fabricjs/fabric.js/blob' ,
58- entryFileName : 'index.md' ,
59- includeVersion : true ,
60- sourceLinkExternal : true ,
61- sourceLinkTemplate : 'https://github.com/fabricjs/fabric.js/blob/{gitRevision}/{path}#L{line}' ,
62- } ,
63- } ) ,
64- ] ,
51+ // Generate the documentation only if local sources exist.
52+ // This avoids dev crashes when `fabric.js` sources are not checked out.
53+ ( fs . existsSync ( new URL ( './fabric.js/fabric.ts' , import . meta. url ) ) &&
54+ fs . existsSync ( new URL ( './fabric.js/typedoc.config.json' , import . meta. url ) ) ) &&
55+ starlightTypeDoc ( {
56+ entryPoints : [ './fabric.js/fabric.ts' ] ,
57+ tsconfig : './fabric.js/typedoc.config.json' ,
58+ typeDoc : {
59+ plugin : [ 'typedoc-plugin-no-inherit' ] ,
60+ readme : 'none' ,
61+ gitRemote : 'https://github.com/fabricjs/fabric.js/blob' ,
62+ entryFileName : 'index.md' ,
63+ includeVersion : true ,
64+ sourceLinkExternal : true ,
65+ sourceLinkTemplate : 'https://github.com/fabricjs/fabric.js/blob/{gitRevision}/{path}#L{line}' ,
66+ } ,
67+ } ) ,
68+ ] . filter ( Boolean ) ,
6569 } ) , react ( ) , sitemap ( ) ] ,
6670} ) ;
0 commit comments