File tree Expand file tree Collapse file tree 5 files changed +29
-3
lines changed Expand file tree Collapse file tree 5 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ coverage
16
16
.env.test
17
17
18
18
# build output
19
- dist
20
19
.vercel
21
20
22
21
# OS-specific
Original file line number Diff line number Diff line change 1
1
src /*
2
- dist /*
2
+ dist /client /*
3
+ dist /server /*
3
4
! src /entry-client.ts
4
5
! src /entry-server.ts
Original file line number Diff line number Diff line change
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' ) ;
Original file line number Diff line number Diff line change 7
7
"prepare" : " node scripts/create-app-svelte.js" ,
8
8
"dev" : " vite --host" ,
9
9
"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" ,
11
12
"preview" : " vite preview"
12
13
},
13
14
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ import inspect from 'vite-plugin-inspect';
3
3
import { svelte } from '@sveltejs/vite-plugin-svelte' ;
4
4
5
5
export default defineConfig ( {
6
+ build : {
7
+ minify : false
8
+ } ,
6
9
plugins : [ inspect ( ) , svelte ( ) ] ,
7
10
optimizeDeps : {
8
11
// svelte is a local workspace package, optimizing it would require dev server restarts with --force for every change
You can’t perform that action at this time.
0 commit comments