mirror of https://github.com/sveltejs/svelte
add pnpm prod command to playground (#11697)
parent
a5fd28a14b
commit
506f9d2892
@ -1,4 +1,5 @@
|
|||||||
src/*
|
src/*
|
||||||
dist/*
|
dist/client/*
|
||||||
|
dist/server/*
|
||||||
!src/entry-client.ts
|
!src/entry-client.ts
|
||||||
!src/entry-server.ts
|
!src/entry-server.ts
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
import express from 'express';
|
||||||
|
import { head, html } from './server/entry-server.js';
|
||||||
|
|
||||||
|
const rendered = fs
|
||||||
|
.readFileSync(path.resolve('./dist/client/index.html'), 'utf-8')
|
||||||
|
.replace(`<!--ssr-html-->`, html)
|
||||||
|
.replace(`<!--ssr-head-->`, head);
|
||||||
|
|
||||||
|
express()
|
||||||
|
.use('*', async (req, res) => {
|
||||||
|
if (req.originalUrl !== '/') {
|
||||||
|
res.sendFile(path.resolve('./dist/client' + req.originalUrl));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.status(200).set({ 'Content-Type': 'text/html' }).end(rendered);
|
||||||
|
})
|
||||||
|
.listen('3000');
|
||||||
|
|
||||||
|
console.log('listening on http://localhost:3000');
|
Loading…
Reference in new issue