File size: 980 Bytes
d240dd4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import { defineConfig, type Plugin } from "vite";
import { svelte, vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const dir = path.resolve(__dirname);
console.log({ dir });
function gradioPlugin(): Plugin {
console.log("Initializing gradio plugin");
return {
enforce: "pre",
name: "gradio",
resolveId(id, importer) {
if (id.startsWith("@gradio/image")) {
return path.resolve(
dir,
"node_modules",
"@gradio",
"image",
"Index.svelte"
);
}
}
};
}
export default defineConfig({
plugins: [svelte({ preprocess: vitePreprocess() }), gradioPlugin()],
resolve: {
conditions: ["gradio", "svelte", "browser", "import", "default"]
},
build: {
minify: false,
sourcemap: true,
lib: {
entry: "./Index.svelte",
formats: ["es"],
fileName: "index"
}
}
});
|