mermaid/.vite/server.ts

29 lines
803 B
TypeScript
Raw Normal View History

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());
app.use(express.static('./packages/mermaid/dist'));
app.use(express.static('./packages/mermaid-example-diagram/dist'));
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();