Skip to content

Commit 506f9d2

Browse files
authored
add pnpm prod command to playground (#11697)
1 parent a5fd28a commit 506f9d2

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ coverage
1616
.env.test
1717

1818
# build output
19-
dist
2019
.vercel
2120

2221
# OS-specific

playgrounds/demo/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
src/*
2-
dist/*
2+
dist/client/*
3+
dist/server/*
34
!src/entry-client.ts
45
!src/entry-server.ts

playgrounds/demo/dist/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import express from 'express';
4+
import { head, html } from './server/entry-server.js';
5+
6+
const rendered = fs
7+
.readFileSync(path.resolve('./dist/client/index.html'), 'utf-8')
8+
.replace(`<!--ssr-html-->`, html)
9+
.replace(`<!--ssr-head-->`, head);
10+
11+
express()
12+
.use('*', async (req, res) => {
13+
if (req.originalUrl !== '/') {
14+
res.sendFile(path.resolve('./dist/client' + req.originalUrl));
15+
return;
16+
}
17+
18+
res.status(200).set({ 'Content-Type': 'text/html' }).end(rendered);
19+
})
20+
.listen('3000');
21+
22+
console.log('listening on http://localhost:3000');

playgrounds/demo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"prepare": "node scripts/create-app-svelte.js",
88
"dev": "vite --host",
99
"ssr": "node ./server.js",
10-
"build": "vite build",
10+
"build": "vite build --outDir dist/client && vite build --outDir dist/server --ssr src/entry-server.ts",
11+
"prod": "npm run build && node dist",
1112
"preview": "vite preview"
1213
},
1314
"devDependencies": {

playgrounds/demo/vite.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import inspect from 'vite-plugin-inspect';
33
import { svelte } from '@sveltejs/vite-plugin-svelte';
44

55
export default defineConfig({
6+
build: {
7+
minify: false
8+
},
69
plugins: [inspect(), svelte()],
710
optimizeDeps: {
811
// svelte is a local workspace package, optimizing it would require dev server restarts with --force for every change

0 commit comments

Comments
 (0)