2024-01-09 00:31:06 +01:00
|
|
|
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
|
|
|
|
2024-01-09 00:31:06 +01:00
|
|
|
dns.setDefaultResultOrder("verbatim")
|
2023-06-04 04:28:07 +02:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
2024-08-07 20:09:51 +02:00
|
|
|
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,
|
2024-01-09 00:31:06 +01:00
|
|
|
host: "localhost"
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
define: {
|
2024-01-09 00:31:06 +01:00
|
|
|
"process.env": process.env
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
css: {
|
2024-01-09 00:31:06 +01:00
|
|
|
postcss
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
visualizer({
|
|
|
|
template: "treemap", // or sunburst
|
|
|
|
open: false,
|
|
|
|
gzipSize: true,
|
|
|
|
brotliSize: true,
|
2024-01-09 00:31:06 +01:00
|
|
|
filename: "bundleinspector.html" // will be saved in project's root
|
|
|
|
})
|
2023-06-04 04:28:07 +02:00
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
alias: [
|
2024-01-09 00:31:06 +01:00
|
|
|
{
|
|
|
|
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) => {
|
2024-01-09 00:31:06 +01:00
|
|
|
return val.replace(/^~/, "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
build: {
|
2024-02-07 22:36:20 +01:00
|
|
|
rollupOptions: {
|
2024-07-20 00:58:43 +02:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
},
|
2024-02-07 22:36:20 +01:00
|
|
|
external: [
|
|
|
|
// Reduces transformation time by 50% and we don't even use this variant, so we can ignore.
|
2024-08-07 20:09:51 +02:00
|
|
|
/@phosphor-icons\/react\/dist\/ssr/,
|
2024-02-07 22:36:20 +01:00
|
|
|
]
|
|
|
|
},
|
2023-06-04 04:28:07 +02:00
|
|
|
commonjsOptions: {
|
2024-01-09 00:31:06 +01:00
|
|
|
transformMixedEsModules: true
|
2023-06-04 04:28:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimizeDeps: {
|
2024-08-07 20:09:51 +02:00
|
|
|
include: ["@mintplex-labs/piper-tts-web"],
|
2023-06-04 04:28:07 +02:00
|
|
|
esbuildOptions: {
|
|
|
|
define: {
|
2024-01-09 00:31:06 +01:00
|
|
|
global: "globalThis"
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
2024-01-09 00:31:06 +01:00
|
|
|
plugins: []
|
2023-06-04 04:28:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|