add pnpm prod command to playground (#11697)

pull/11663/head
Rich Harris 7 months ago committed by GitHub
parent a5fd28a14b
commit 506f9d2892
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

1
.gitignore vendored

@ -16,7 +16,6 @@ coverage
.env.test
# build output
dist
.vercel
# OS-specific

@ -1,4 +1,5 @@
src/*
dist/*
dist/client/*
dist/server/*
!src/entry-client.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');

@ -7,7 +7,8 @@
"prepare": "node scripts/create-app-svelte.js",
"dev": "vite --host",
"ssr": "node ./server.js",
"build": "vite build",
"build": "vite build --outDir dist/client && vite build --outDir dist/server --ssr src/entry-server.ts",
"prod": "npm run build && node dist",
"preview": "vite preview"
},
"devDependencies": {

@ -3,6 +3,9 @@ import inspect from 'vite-plugin-inspect';
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
build: {
minify: false
},
plugins: [inspect(), svelte()],
optimizeDeps: {
// svelte is a local workspace package, optimizing it would require dev server restarts with --force for every change

Loading…
Cancel
Save