mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
65f114a117
* add error handling for version.json * tweak error * add changeset * formatting * tweak logic * fix build * tweak * fix ENOENT error during build * revert removal of 3.50.2 routes Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
import adapter from "@sveltejs/adapter-static";
|
|
import { vitePreprocess } from "@sveltejs/kit/vite";
|
|
import { redirects } from "./src/routes/redirects.js";
|
|
import fs from "fs";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
let version = "4.0.0";
|
|
|
|
const get_version = async () => {
|
|
try {
|
|
const versionPath = path.join(
|
|
currentDir,
|
|
"src",
|
|
"lib",
|
|
"json",
|
|
"version.json"
|
|
);
|
|
if (!fs.existsSync(versionPath)) {
|
|
console.error(
|
|
"Using fallback version 4.0.0 as version.json was not found. Run `generate_jsons/generate.py` to get the latest version."
|
|
);
|
|
return version;
|
|
} else {
|
|
const versionData = fs.readFileSync(versionPath, "utf8");
|
|
const versionJson = JSON.parse(versionData);
|
|
version = versionJson.version;
|
|
}
|
|
} catch (error) {
|
|
console.error(
|
|
"Using fallback version 4.0.0 as version.json was not found. Run `generate_jsons/generate.py` to get the latest version."
|
|
);
|
|
}
|
|
return version;
|
|
};
|
|
|
|
get_version();
|
|
|
|
/** @type {import('@sveltejs/kit').Config} */
|
|
const config = {
|
|
preprocess: vitePreprocess(),
|
|
kit: {
|
|
prerender: {
|
|
crawl: true,
|
|
entries: [
|
|
"*",
|
|
`/${version}/docs`,
|
|
`/${version}/guides`,
|
|
`/main/docs`,
|
|
`/main/guides`,
|
|
`/main/docs/js`,
|
|
`/main/docs/js/storybook`,
|
|
`/main/docs/js/`,
|
|
`/3.50.2/docs`,
|
|
`/3.50.2/guides`,
|
|
...Object.keys(redirects)
|
|
]
|
|
},
|
|
files: {
|
|
lib: "src/lib"
|
|
},
|
|
adapter: adapter()
|
|
}
|
|
};
|
|
|
|
export default config;
|