This commit is contained in:
wt 2025-02-14 12:12:10 -08:00 committed by GitHub
commit b3a75113a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 89 additions and 69 deletions

View file

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

9
pnpm-lock.yaml generated Normal file
View file

@ -0,0 +1,9 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.: {}