anything-llm/frontend/vite.config.js

88 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

import { defineConfig } from "vite"
import { fileURLToPath, URL } from "url"
import postcss from "./postcss.config.js"
import react from "@vitejs/plugin-react"
import dns from "dns"
import { visualizer } from "rollup-plugin-visualizer"
2023-06-04 04:28:07 +02:00
dns.setDefaultResultOrder("verbatim")
2023-06-04 04:28:07 +02:00
// https://vitejs.dev/config/
export default defineConfig({
assetsInclude: [
'./public/piper/ort-wasm-simd-threaded.wasm',
'./public/piper/piper_phonemize.wasm',
'./public/piper/piper_phonemize.data',
],
worker: {
format: 'es'
},
2023-06-04 04:28:07 +02:00
server: {
port: 3000,
host: "localhost"
2023-06-04 04:28:07 +02:00
},
define: {
"process.env": process.env
2023-06-04 04:28:07 +02:00
},
css: {
postcss
2023-06-04 04:28:07 +02:00
},
plugins: [
react(),
visualizer({
template: "treemap", // or sunburst
open: false,
gzipSize: true,
brotliSize: true,
filename: "bundleinspector.html" // will be saved in project's root
})
2023-06-04 04:28:07 +02:00
],
resolve: {
alias: [
{
find: "@",
replacement: fileURLToPath(new URL("./src", import.meta.url))
},
2023-06-04 04:28:07 +02:00
{
process: "process/browser",
stream: "stream-browserify",
zlib: "browserify-zlib",
util: "util",
find: /^~.+/,
replacement: (val) => {
return val.replace(/^~/, "")
}
}
]
2023-06-04 04:28:07 +02:00
},
build: {
rollupOptions: {
output: {
// These settings ensure the primary JS and CSS file references are always index.{js,css}
// so we can SSR the index.html as text response from server/index.js without breaking references each build.
entryFileNames: 'index.js',
assetFileNames: (assetInfo) => {
if (assetInfo.name === 'index.css') return `index.css`;
return assetInfo.name;
},
},
external: [
// Reduces transformation time by 50% and we don't even use this variant, so we can ignore.
/@phosphor-icons\/react\/dist\/ssr/,
]
},
2023-06-04 04:28:07 +02:00
commonjsOptions: {
transformMixedEsModules: true
2023-06-04 04:28:07 +02:00
}
},
optimizeDeps: {
include: ["@mintplex-labs/piper-tts-web"],
2023-06-04 04:28:07 +02:00
esbuildOptions: {
define: {
global: "globalThis"
2023-06-04 04:28:07 +02:00
},
plugins: []
2023-06-04 04:28:07 +02:00
}
}
})