import { svelte } from "@sveltejs/vite-plugin-svelte" import { defineConfig } from "vite" import path from "path" import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js" const ignoredWarnings = [ "unused-export-let", "css-unused-selector", "module-script-reactive-declaration", "a11y-no-onchange", "a11y-click-events-have-key-events", ] export default defineConfig(({ mode }) => { const isProduction = mode === "production" return { server: { open: false, }, build: { lib: { entry: "src/index.js", formats: ["iife"], outDir: "dist", name: "budibase_client", fileName: () => "budibase-client.js", minify: isProduction, }, }, plugins: [ svelte({ emitCss: true, onwarn: (warning, handler) => { // Ignore some warnings if (!ignoredWarnings.includes(warning.code)) { handler(warning) } }, }), cssInjectedByJsPlugin(), ], resolve: { dedupe: ["svelte", "svelte/internal"], alias: [ { find: "manifest.json", replacement: path.resolve("./manifest.json"), }, { find: "api", replacement: path.resolve("./src/api"), }, { find: "components", replacement: path.resolve("./src/components"), }, { find: "stores", replacement: path.resolve("./src/stores"), }, { find: "utils", replacement: path.resolve("./src/utils"), }, { find: "constants", replacement: path.resolve("./src/constants"), }, { find: "sdk", replacement: path.resolve("./src/sdk"), }, { find: "@budibase/types", replacement: path.resolve("../types/src"), }, { find: "@budibase/shared-core", replacement: path.resolve("../shared-core/src"), }, { find: "@budibase/bbui", replacement: path.resolve("../bbui/src"), }, ], }, } })