Skip to content

Commit

Permalink
Merge pull request #1749 from SUI-Components/fix/copy-html-files-dev-ssr
Browse files Browse the repository at this point in the history
Fix/copy html files dev ssr
  • Loading branch information
andresz1 authored Apr 5, 2024
2 parents 5ceed50 + b692c3e commit 1cf256b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/sui-ssr/bin/sui-ssr-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const program = require('commander')
const {exec} = require('child_process')
const {cp} = require('fs/promises')
const path = require('path')
const fs = require('fs')
const express = require('express')
Expand All @@ -19,6 +20,8 @@ const log = require('@s-ui/bundler/shared/log.js')
const serverConfigFactory = require('../compiler/server.js')

const TMP_PATH = '.sui'
const SRC_PATH = path.join(process.cwd(), 'src')
const PUBLIC_OUTPUT_PATH = path.join(process.cwd(), `${TMP_PATH}/public`)
const SERVER_OUTPUT_PATH = path.join(process.cwd(), `${TMP_PATH}/server`)
const STATICS_PATH = path.join(process.cwd(), './statics')
const STATICS_OUTPUT_PATH = path.join(process.cwd(), `${TMP_PATH}/statics`)
Expand Down Expand Up @@ -63,6 +66,13 @@ const linkStatics = () => {
)
}

const copyStatics = () => {
return Promise.allSettled([
cp(path.join(SRC_PATH, '404.html'), path.join(PUBLIC_OUTPUT_PATH, '404.html'), {recursive: true}),
cp(path.join(SRC_PATH, '500.html'), path.join(PUBLIC_OUTPUT_PATH, '500.html'), {recursive: true})
])
}

const initMSW = () => {
return exec(`npx msw init ${STATICS_PATH}`)
}
Expand Down Expand Up @@ -153,7 +163,13 @@ const start = async ({packagesToLink, linkAll}) => {
fs.mkdirSync(TMP_PATH)
}

Promise.all([linkStatics(), initMSW(), compile('client', clientCompiler), compile('server', serverCompiler)])
Promise.all([
linkStatics(),
initMSW(),
copyStatics(),
compile('client', clientCompiler),
compile('server', serverCompiler)
])
.then(() => {
const script = nodemon({
script: `${SERVER_OUTPUT_PATH}/index.js`,
Expand Down

0 comments on commit 1cf256b

Please sign in to comment.