Skip to content

Commit

Permalink
Fix Vite build configuration for ES modules and proper asset loading
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Jan 30, 2025
1 parent 8acfb09 commit a8e2298
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"scripts": {
"dev": "npm run make-i18n && cross-env VITE_MOCK_API=false react-router dev",
"dev:mock": "npm run make-i18n && cross-env VITE_MOCK_API=true react-router dev",
"build": "npm run make-i18n && tsc && vite build",
"build": "npm run make-i18n && tsc && VITE_BACKEND_HOST=https://work-1-ekyftbovqnpqjfeu.prod-runtime.all-hands.dev VITE_FRONTEND_PORT=12000 vite build",
"start": "npx sirv-cli build/ --single",
"test": "vitest run",
"test:e2e": "playwright test",
Expand Down
19 changes: 19 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default defineConfig(({ mode }) => {
const FE_PORT = Number.parseInt(VITE_FRONTEND_PORT, 10);

return {
base: '/',
plugins: [
!process.env.VITEST && reactRouter(),
viteTsconfigPaths(),
Expand Down Expand Up @@ -66,5 +67,23 @@ export default defineConfig(({ mode }) => {
include: ["src/**/*.{ts,tsx}"],
},
},
build: {
modulePreload: false,
target: 'esnext',
minify: 'esbuild',
rollupOptions: {
output: {
format: 'esm',
entryFileNames: '[name]-[hash].js',
chunkFileNames: '[name]-[hash].js',
assetFileNames: '[name]-[hash].[ext]'
}
}
},
optimizeDeps: {
esbuildOptions: {
target: 'esnext'
}
},
};
});

0 comments on commit a8e2298

Please sign in to comment.