2023-02-19 14:03:11 +05:30
|
|
|
import express from 'express';
|
|
|
|
import cors from 'cors';
|
2022-09-23 10:56:39 +05:30
|
|
|
import { createServer as createViteServer } from 'vite';
|
2023-11-24 10:54:43 +05:30
|
|
|
import { packageOptions } from '../.build/common.js';
|
2022-10-17 14:01:44 +05:30
|
|
|
|
2022-09-22 15:35:22 +05:30
|
|
|
async function createServer() {
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
// Create Vite server in middleware mode
|
|
|
|
const vite = await createViteServer({
|
|
|
|
configFile: './vite.config.ts',
|
2022-11-20 11:09:08 +05:30
|
|
|
mode: 'production',
|
2022-09-22 15:35:22 +05:30
|
|
|
server: { middlewareMode: true },
|
2023-02-20 21:23:06 +05:30
|
|
|
appType: 'custom', // don't include Vite's default HTML handling middleware
|
2022-09-22 15:35:22 +05:30
|
|
|
});
|
|
|
|
|
2023-02-19 14:18:09 +05:30
|
|
|
app.use(cors());
|
2023-11-24 10:54:43 +05:30
|
|
|
for (const { packageName } of Object.values(packageOptions)) {
|
|
|
|
app.use(express.static(`./packages/${packageName}/dist`));
|
|
|
|
}
|
2022-10-03 10:05:12 +02:00
|
|
|
app.use(vite.middlewares);
|
2022-09-22 15:35:22 +05:30
|
|
|
app.use(express.static('demos'));
|
|
|
|
app.use(express.static('cypress/platform'));
|
|
|
|
|
|
|
|
app.listen(9000, () => {
|
2024-06-29 16:20:46 +05:30
|
|
|
// eslint-disable-next-line no-console
|
2022-09-22 15:35:22 +05:30
|
|
|
console.log(`Listening on http://localhost:9000`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-06-29 16:20:46 +05:30
|
|
|
void createServer();
|