UNPKG

react-cosmos

Version:

Sandbox for developing and testing UI components in isolation

21 lines (20 loc) 826 B
import express from 'express'; import { getDevPlaygroundHtml } from '../shared/playgroundHtml.js'; import { getStaticPath } from '../shared/staticPath.js'; import { resolve } from '../utils/resolve.js'; export async function createExpressApp(platform, config, pluginConfigs) { const app = express(); app.get('/', async (_, res) => { res.send(await getDevPlaygroundHtml(platform, config, pluginConfigs)); }); app.get('/playground.bundle.js', (_, res) => { res.sendFile(resolve('react-cosmos-ui/dist/playground.bundle.js')); }); app.get('/playground.bundle.js.map', (_, res) => { res.sendFile(resolve('react-cosmos-ui/dist/playground.bundle.js.map')); }); app.get('/_cosmos.ico', (_, res) => { res.sendFile(getStaticPath('favicon.ico')); }); return app; }