using jsx
This commit is contained in:
parent
5f0c06216d
commit
adf5dde73c
@ -1,35 +1,20 @@
|
||||
FROM docker.io/oven/bun as base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# install dependencies into temp directory
|
||||
FROM base AS install
|
||||
RUN mkdir -p /temp/dev
|
||||
COPY package.json bun.lockb /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
WORKDIR /modules
|
||||
COPY package.json bun.lockb /modules/
|
||||
RUN bun install --frozen-lockfile --production
|
||||
|
||||
# install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lockb /temp/prod/
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
|
||||
# copy node_modules from temp directory
|
||||
# then copy all (non-ignored) project files into the image
|
||||
FROM base AS prerelease
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY . .
|
||||
|
||||
# [optional] tests & build
|
||||
ENV NODE_ENV=production
|
||||
RUN bun test
|
||||
RUN bun run build
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
COPY --from=install /temp/prod/node_modules node_modules
|
||||
COPY --from=prerelease /usr/src/app/index.ts .
|
||||
COPY --from=prerelease /usr/src/app/package.json .
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --from=install /modules/node_modules node_modules
|
||||
COPY src .
|
||||
|
||||
# run the app
|
||||
USER bun
|
||||
EXPOSE 3000/tcp
|
||||
ENTRYPOINT [ "bun", "run", "index.ts" ]
|
||||
ENTRYPOINT [ "bun", "run", "index.tsx" ]
|
||||
|
@ -4,9 +4,9 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"dev": "bun run tailwind:dev | bun run elxsia:dev",
|
||||
"elxsia:dev": "bun --watch src/index.ts",
|
||||
"elxsia:dev": "bun --watch src/index.tsx",
|
||||
"build": "bun run tailwind:build",
|
||||
"start": "bun run src/index.ts",
|
||||
"start": "bun run src/index.tsx",
|
||||
"tailwind:build": "bunx tailwindcss -i ./src/style.css -o ./public/style.css --minify",
|
||||
"tailwind:dev": "bunx tailwindcss -i ./src/style.css -o ./public/style.css --watch"
|
||||
},
|
||||
|
@ -6,6 +6,8 @@ import { staticPlugin } from "@elysiajs/static";
|
||||
// // @ts-ignore
|
||||
// import data from "../package.json";
|
||||
|
||||
import { HomeLayout } from "./layout";
|
||||
|
||||
export const server = new Elysia()
|
||||
.use(html())
|
||||
.use(staticPlugin())
|
||||
@ -17,12 +19,11 @@ export const server = new Elysia()
|
||||
.onError(({ code, error }) => {
|
||||
console.error(code, error);
|
||||
})
|
||||
.get("/", () => "Hello World")
|
||||
.get("/", ({html}) => html(<HomeLayout><div>hello world</div></HomeLayout>))
|
||||
|
||||
.listen(Bun.env["PORT"] ?? 3000);
|
||||
|
||||
|
||||
|
||||
console.log(
|
||||
`app is running at ${server.server?.hostname}:${server.server?.port}`,
|
||||
);
|
23
frontend/src/layout.tsx
Normal file
23
frontend/src/layout.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import { html } from "@elysiajs/html";
|
||||
const HomeLayout = ({ children }: elements.Children) => `
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="https://unpkg.com/htmx.org@1.9.5"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link href="/public/style.css" rel="stylesheet" type="text/css" />
|
||||
// not working
|
||||
<title>BETH STACK</title>
|
||||
</head>
|
||||
<body class="h-screen w-screen flex flex-col gap-3 items-center justify-center">
|
||||
<span class='text-xl font-semibold'>BETH STACK</span>
|
||||
<div class='flex flex-col items-center justify-center gap-2 mb-5'>
|
||||
<span class='text-neutral-500 font-semibold'>Bun 1.0</span>
|
||||
<span class='text-violet-500 font-semibold'>Elysia</span>
|
||||
<span class='text-lime-500 font-semibold'>Turso</span>
|
||||
<span class='text-sky-500 font-semibold'>Htmx</span>
|
||||
</div>
|
||||
${children}
|
||||
</body>
|
||||
`;
|
||||
|
||||
export { HomeLayout }
|
@ -1,5 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
|
||||
"jsx": "react",
|
||||
"jsxFactory": "Html.createElement",
|
||||
"jsxFragmentFactory": "Html.Fragment",
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
|
Loading…
x
Reference in New Issue
Block a user