-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathvite.config.js
More file actions
49 lines (46 loc) · 1.41 KB
/
vite.config.js
File metadata and controls
49 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import path from "path";
import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";
import vue from "@vitejs/plugin-vue";
// https://vite.dev/config/
export default defineConfig({
base: process.env.NODE_ENV === 'production' ? '/tts-studio/' : '/',
plugins: [
tailwindcss(),
vue(),
{
name: 'onnx-wasm-plugin',
configureServer(server) {
server.middlewares.use('/onnx-runtime', (req, res, next) => {
// Strip ?import parameter from ONNX requests
if (req.url.includes('?import')) {
req.url = req.url.replace('?import', '');
}
if (req.url.endsWith('.mjs')) {
res.setHeader('Content-Type', 'application/javascript');
res.setHeader('Access-Control-Allow-Origin', '*');
}
next();
});
// Add caching for model files
server.middlewares.use('/tts-model', (req, res, next) => {
// Cache model files for 7 days (604800 seconds)
res.setHeader('Cache-Control', 'public, max-age=604800, immutable');
res.setHeader('ETag', `"model-v1"`);
next();
});
}
}
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
worker: { format: "es" },
build: {
target: "esnext",
},
assetsInclude: ['**/*.wasm'],
logLevel: process.env.NODE_ENV === "development" ? "error" : "info",
});