anything-llm/embed/vite.config.js

65 lines
1.5 KiB
JavaScript
Raw Normal View History

2024-01-25 02:20:26 +01:00
// vite.config.js
2024-01-31 18:23:08 +01:00
import { defineConfig } from "vite"
import { fileURLToPath, URL } from "url"
2024-01-31 18:23:08 +01:00
import react from "@vitejs/plugin-react"
import image from "@rollup/plugin-image"
2024-01-25 02:20:26 +01:00
export default defineConfig({
2024-01-31 18:23:08 +01:00
plugins: [react(), image()],
define: {
// In dev, we need to disable this, but in prod, we need to enable it
"process.env.NODE_ENV": JSON.stringify("production")
2024-01-25 02:20:26 +01:00
},
resolve: {
alias: [
{
find: "@",
replacement: fileURLToPath(new URL("./src", import.meta.url))
},
{
process: "process/browser",
stream: "stream-browserify",
zlib: "browserify-zlib",
util: "util",
find: /^~.+/,
replacement: (val) => {
return val.replace(/^~/, "")
}
}
]
},
2024-01-25 02:20:26 +01:00
build: {
lib: {
2024-01-31 18:23:08 +01:00
entry: "src/main.jsx",
name: "EmbeddedAnythingLLM",
formats: ["umd"],
2024-01-25 02:20:26 +01:00
fileName: (format) => `embedded-anything-llm.${format}.js`
},
rollupOptions: {
2024-02-01 22:55:37 +01:00
external: [
// Reduces transformation time by 50% and we don't even use this variant, so we can ignore.
/@phosphor-icons\/react\/dist\/ssr/,
]
2024-01-25 02:20:26 +01:00
},
commonjsOptions: {
transformMixedEsModules: true
},
2024-01-25 02:20:26 +01:00
cssCodeSplit: false,
assetsInlineLimit: 100000000,
2024-01-31 18:23:08 +01:00
minify: "esbuild",
outDir: "dist",
2024-01-25 02:20:26 +01:00
emptyOutDir: true,
inlineDynamicImports: true,
assetsDir: "",
sourcemap: 'inline',
},
optimizeDeps: {
esbuildOptions: {
define: {
global: "globalThis"
},
plugins: []
}
},
2024-01-31 18:23:08 +01:00
})