import { defineConfig, normalizePath } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import baseTailwind from '../../tailwind.config.js';
const root = path.dirname(fileURLToPath(import.meta.url));
const webui = path.resolve(root, '../..');
const repository = path.dirname(webui);
const realAutomations = normalizePath(path.join(webui, 'src/components/settings/system/AutomationsSettings.tsx'));
const linkedChat = `
{!job.protected && job.origin?.channel && job.origin.channel !== "websocket" ? (
{automationChannelLabel(job.origin.channel, t)}
) : null}
`;
const panelStart = ' `)
.replace(panelStart, ' '),
map: null,
};
},
}, react()],
resolve: {
alias: { '@': path.join(webui, 'src') },
dedupe: ['react', 'react-dom', 'lucide-react', 'react-i18next', 'i18next'],
},
css: {
postcss: {
plugins: [tailwindcss({
...baseTailwind,
content: [
normalizePath(path.join(webui, 'src/**/*.{ts,tsx}')),
normalizePath(path.join(repository, 'nanobot/channels/*/webui/**/*.{ts,tsx}')),
normalizePath(path.join(webui, 'node_modules/streamdown/dist/*.js')),
normalizePath(path.join(root, '*.{tsx,html}')),
],
}), autoprefixer()],
},
},
// No API proxy. The proposal must not talk to an installed gateway.
server: { host: '127.0.0.1', port: 53822, strictPort: true, fs: { allow: [repository] } },
preview: { host: '127.0.0.1', port: 53822, strictPort: true },
build: { outDir: path.join(root, 'dist') },
});