Files
Fabric/web/vite.config.ts

70 lines
1.9 KiB
TypeScript

import { purgeCss } from 'vite-plugin-tailwind-purgecss';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit(), purgeCss()],
build: {
commonjsOptions: {
transformMixedEsModules: true
}
},
define: {
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
},
'process.platform': JSON.stringify(process.platform),
'process.cwd': JSON.stringify('/'),
'process.browser': true,
'process': {
cwd: () => ('/')
}
},
resolve: {
alias: {
process: 'process/browser'
}
},
server: {
fs: {
allow: ['..'] // allows importing from the parent directory
},
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
timeout: 30000,
rewrite: (path) => path.replace(/^\/api/, ''),
configure: (proxy, options) => {
proxy.on('error', (err, req, res) => {
console.log('proxy error', err);
res.writeHead(500, {
'Content-Type': 'text/plain',
});
res.end('Something went wrong. The backend server may not be running.');
});
}
},
'^/(patterns|models|sessions)/names': {
target: 'http://localhost:8080',
changeOrigin: true,
timeout: 30000,
configure: (proxy, options) => {
proxy.on('error', (err, req, res) => {
console.log('proxy error', err);
res.writeHead(500, {
'Content-Type': 'application/json',
});
res.end(JSON.stringify({ error: 'Backend server not running', names: [] }));
});
}
}
},
watch: {
usePolling: true,
interval: 100,
ignored: ['**/node_modules/**', '**/dist/**', '**/.git/**', '**/.svelte-kit/**']
}
},
});