mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
31 lines
865 B
TypeScript
31 lines
865 B
TypeScript
import express from 'express';
|
|
import cors from 'cors';
|
|
import { createServer as createViteServer } from 'vite';
|
|
import { packageOptions } from '../.build/common.js';
|
|
|
|
async function createServer() {
|
|
const app = express();
|
|
|
|
// Create Vite server in middleware mode
|
|
const vite = await createViteServer({
|
|
configFile: './vite.config.ts',
|
|
mode: 'production',
|
|
server: { middlewareMode: true },
|
|
appType: 'custom', // don't include Vite's default HTML handling middleware
|
|
});
|
|
|
|
app.use(cors());
|
|
for (const { packageName } of Object.values(packageOptions)) {
|
|
app.use(express.static(`./packages/${packageName}/dist`));
|
|
}
|
|
app.use(vite.middlewares);
|
|
app.use(express.static('demos'));
|
|
app.use(express.static('cypress/platform'));
|
|
|
|
app.listen(9000, () => {
|
|
console.log(`Listening on http://localhost:9000`);
|
|
});
|
|
}
|
|
|
|
createServer();
|