Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion packages/migrate/src/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,21 @@ export async function detect(projectDir: string): Promise<DetectionResult> {
' // vite.config.ts\n' +
" import { defineConfig } from 'vite';\n" +
" import react from '@vitejs/plugin-react';\n" +
" import { join } from 'node:path';\n" +
'\n' +
' export default defineConfig({\n' +
' plugins: [react()],\n' +
" define: { CUSTOM: JSON.stringify('value') },\n" +
' build: {\n' +
' rollupOptions: {\n' +
" input: join(__dirname, 'src/web/index.html'),\n" +
' },\n' +
' },\n' +
' });\n' +
'\n' +
'The build.rollupOptions.input is required so Vite finds your\n' +
'HTML entry point at src/web/index.html.\n' +
Comment thread
Huijiro marked this conversation as resolved.
'\n' +
'After creating vite.config.ts, delete agentuity.config.ts.',
});
}
Expand Down Expand Up @@ -712,14 +721,21 @@ export async function detect(projectDir: string): Promise<DetectionResult> {
severity: 'guided',
message: 'No vite.config.ts found - frontend requires Vite configuration',
hint:
'Create vite.config.ts with your frontend framework plugin:\n' +
'Create vite.config.ts with your frontend framework plugin.\n' +
'The build.rollupOptions.input must point to src/web/index.html:\n' +
'\n' +
' // vite.config.ts\n' +
" import { defineConfig } from 'vite';\n" +
" import react from '@vitejs/plugin-react';\n" +
" import { join } from 'node:path';\n" +
'\n' +
' export default defineConfig({\n' +
' plugins: [react()],\n' +
' build: {\n' +
' rollupOptions: {\n' +
" input: join(__dirname, 'src/web/index.html'),\n" +
' },\n' +
' },\n' +
' });\n' +
'\n' +
'For other frameworks:\n' +
Expand All @@ -729,6 +745,33 @@ export async function detect(projectDir: string): Promise<DetectionResult> {
});
}

// If vite.config.ts exists but is missing build.rollupOptions.input, warn about it
if (hasFrontend && hasViteConfig) {
const viteSrc = await Bun.file(viteConfigPath).text();
if (!viteSrc.includes('rollupOptions') || !viteSrc.includes('index.html')) {
findings.push({
Comment thread
Huijiro marked this conversation as resolved.
Outdated
id: 'vite-config-missing-rollup-input',
severity: 'guided',
message: 'vite.config.ts may be missing build.rollupOptions.input',
file: 'vite.config.ts',
hint:
'Agentuity expects the HTML entry point at src/web/index.html.\n' +
'Add build.rollupOptions.input to your vite.config.ts:\n' +
'\n' +
" import { join } from 'node:path';\n" +
'\n' +
' export default defineConfig({\n' +
' // ...your existing config\n' +
' build: {\n' +
' rollupOptions: {\n' +
" input: join(__dirname, 'src/web/index.html'),\n" +
' },\n' +
' },\n' +
' });',
});
}
}

if (hasApiRoutes && hasFrontend && result.frontendRemovedApis.length === 0) {
// Only show this if there are no already-detected frontend issues (avoid duplication)
findings.push({
Expand Down
14 changes: 14 additions & 0 deletions templates/default/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';
import { join } from 'node:path';

export default defineConfig({
plugins: [react(), tailwindcss()],
root: '.',
build: {
rollupOptions: {
input: join(__dirname, 'src/web/index.html'),
Comment thread
Huijiro marked this conversation as resolved.
Outdated
},
},
});
Loading