Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
File renamed without changes.
File renamed without changes.
22 changes: 0 additions & 22 deletions public/admin.html

This file was deleted.

4 changes: 2 additions & 2 deletions public/pull_request.html → pull_request.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<link href="/static/css/style.css" rel="stylesheet" />
<link href="/style.css" rel="stylesheet" />
</head>

<body>
<div class="bg"></div>
<div class="container">
<div id="app"></div>
</div>
<script src="/static/js/main.js"></script>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
22 changes: 15 additions & 7 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function startServer() {
});
});

// Proxy API requests to backend - MUST be before Vite middleware
// Proxy API requests to backend - MUST be before static/Vite middleware
app.use('/api', proxy);

// Setup Vite middleware (development only)
Expand All @@ -41,10 +41,15 @@ async function startServer() {
app.use(vite.middlewares);
}

// Serve static files
// Serve static files (landing page, images, css)
app.use(express.static('./public'));

// Static pages (no React)
// In production, serve built assets from dist/
if (isProduction) {
app.use(express.static('./dist'));
}

// Static pages (no React) - served from public/
app.get('/', (req, res) => {
res.sendFile('index.html', { root: './public' });
});
Expand All @@ -57,15 +62,17 @@ async function startServer() {
res.sendFile('privacyPolicy.html', { root: './public' });
});

// React pages - use Vite in development
// React pages - serve from dist/ in production, transform with Vite in development
const serveReactPage = async (req, res, htmlFile) => {
if (isProduction) {
res.sendFile(htmlFile, { root: './public' });
// Serve pre-built HTML from dist/
res.sendFile(htmlFile, { root: './dist' });
} else {
// Transform HTML with Vite (handles JSX imports)
try {
const template = await vite.transformIndexHtml(
req.originalUrl,
fs.readFileSync(path.join('./public', htmlFile), 'utf-8')
fs.readFileSync(path.join('.', htmlFile), 'utf-8')
);
res.setHeader('Content-Type', 'text/html');
res.send(template);
Expand All @@ -80,7 +87,8 @@ async function startServer() {
app.get('/dashboard', (req, res) =>
serveReactPage(req, res, 'dashboard.html')
);
app.get('/admin', (req, res) => serveReactPage(req, res, 'dashboard.html'));

app.get('/admin', (req, res) => serveReactPage(req, res, 'admin.html'));

// PR pages: /:owner/:repo/pull/:number
app.get('/:owner/:repo/pull/:number', (req, res) => {
Expand Down
18 changes: 18 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';

export default defineConfig({
plugins: [react()],

// Don't copy public/ to dist/ - we serve static files separately
publicDir: false,

build: {
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
input: {
dashboard: resolve(__dirname, 'dashboard.html'),
pullRequest: resolve(__dirname, 'pull_request.html'),
admin: resolve(__dirname, 'admin.html'),
},
},
},

server: {
host: '0.0.0.0',
port: 3001,
},

css: {
modules: {
localsConvention: 'camelCaseOnly',
Expand Down