Skip to content

Commit

Permalink
fix serving static files via cli server
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed May 6, 2023
1 parent 258cad5 commit 4ed5170
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 65 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hydration } from "cinnabun/hydration"
import { App } from "../App"
import { App } from "./App"
import { SSRProps } from "cinnabun/src/types"
import "./index.css"

Expand Down
61 changes: 0 additions & 61 deletions apps/ssr-cli/src/server/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cli/src/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
regexPatterns,
replaceServerFunctions,
generateFileRouter,
} = require("./transform.plugin")
} = require("./transform-plugin")

/**
* @type {esbuild.BuildOptions}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/build/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { ComponentFunc } from "cinnabun/src/types"
export function createServer(App: ComponentFunc) {
//const { App } = await import(path.resolve(process.cwd(), "src", "App"))

//console.log("Creating server - App: ", App)
console.log("Creating server", process.cwd())

const app = fastify()

app.register(compress, { global: false })
app.register(fStatic, {
prefix: "/static/",
root: path.join(__dirname, "../../dist/static"),
root: path.join(process.cwd(), "dist", "static"),
})
app.get("/favicon.ico", (_, res) => {
res.status(404).send()
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/routes/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Command, Option } from "commander"
import esbuild from "esbuild"
import { generateFileRouter } from "../build/transform-plugin"
import path from "path"
import { buildClient } from "../build/build"

export default new Command("start")
.description("start your cinnabun project")
Expand Down Expand Up @@ -40,6 +41,8 @@ export default new Command("start")

const { App, createServer } = eval(result.outputFiles![0].text) as any

await buildClient()

createServer(App).listen({ port }, function (err: any) {
if (err) {
console.error(err)
Expand Down

0 comments on commit 4ed5170

Please sign in to comment.