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';
|
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());
|
2022-09-28 19:52:31 +01:00
|
|
|
app.use(express.static('./packages/mermaid/dist'));
|
2022-10-03 07:01:56 +02:00
|
|
|
app.use(express.static('./packages/mermaid-example-diagram/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, () => {
|
|
|
|
console.log(`Listening on http://localhost:9000`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
createServer();
|