From aee3a7a7f2d2cd54da6982d10616d8bb5092cff2 Mon Sep 17 00:00:00 2001 From: OrJDev Date: Wed, 13 Mar 2024 12:35:04 +0200 Subject: [PATCH] fix: move from vite to app config --- .changeset/twenty-socks-hammer.md | 5 +++++ src/helpers/{vite.ts => config.ts} | 18 ++++++------------ src/utils/project.ts | 2 +- .../base/{vite.config.ts => app.config.ts} | 4 +--- template/base/package.json | 3 ++- 5 files changed, 15 insertions(+), 17 deletions(-) create mode 100644 .changeset/twenty-socks-hammer.md rename src/helpers/{vite.ts => config.ts} (51%) rename template/base/{vite.config.ts => app.config.ts} (74%) diff --git a/.changeset/twenty-socks-hammer.md b/.changeset/twenty-socks-hammer.md new file mode 100644 index 0000000..3c9be1a --- /dev/null +++ b/.changeset/twenty-socks-hammer.md @@ -0,0 +1,5 @@ +--- +"create-jd-app": patch +--- + +fix: move from vite to app config diff --git a/src/helpers/vite.ts b/src/helpers/config.ts similarity index 51% rename from src/helpers/vite.ts rename to src/helpers/config.ts index 79d3083..afd6019 100644 --- a/src/helpers/vite.ts +++ b/src/helpers/config.ts @@ -2,24 +2,18 @@ import fs from "fs-extra"; import path from "path"; import type { ICtx, IUtil } from "~types"; -export const getViteConfig: IUtil = (ctx) => { +export const getAppConfig: IUtil = (ctx) => { const usePrisma = ctx.installers.includes("Prisma"); - return `import { defineConfig } from '@solidjs/start/config'${ - ctx.vercel ? `\nimport vercel from "solid-start-vercel";` : "" - } + return `import { defineConfig } from '@solidjs/start/config' export default defineConfig({ - start: { - ssr: true,${ - usePrisma ? `\n ssr: { external: ["@prisma/client"] },` : "" - }${ + ssr: true,${usePrisma ? `\n ssr: { external: ["@prisma/client"] },` : ""}${ ctx.vercel - ? `\n server: { + ? `\n server: { preset: 'vercel', },` : "" } - }, }) `; }; @@ -27,8 +21,8 @@ export default defineConfig({ export const modifyConfigIfNeeded = async (ctx: ICtx) => { if (ctx.vercel || ctx.installers.includes("Prisma")) { await fs.writeFile( - path.join(ctx.userDir, "vite.config.ts"), - getViteConfig(ctx) + path.join(ctx.userDir, "app.config.ts"), + getAppConfig(ctx) ); } }; diff --git a/src/utils/project.ts b/src/utils/project.ts index db2dffc..53c2b5b 100644 --- a/src/utils/project.ts +++ b/src/utils/project.ts @@ -14,7 +14,7 @@ import { } from "./helpers"; import type { IAppCtx, ICtx, IEnv, IVercelOpt } from "~types"; import { updateEnv } from "~helpers/env"; -import { modifyConfigIfNeeded } from "~helpers/vite"; +import { modifyConfigIfNeeded } from "~helpers/config"; import type { IExpectedPackages } from "~helpers/packages"; export async function initApp(args: string[]): Promise { diff --git a/template/base/vite.config.ts b/template/base/app.config.ts similarity index 74% rename from template/base/vite.config.ts rename to template/base/app.config.ts index d19e455..6ebc24f 100644 --- a/template/base/vite.config.ts +++ b/template/base/app.config.ts @@ -1,7 +1,5 @@ import { defineConfig } from "@solidjs/start/config"; export default defineConfig({ - start: { - ssr: true, - }, + ssr: true, }); diff --git a/template/base/package.json b/template/base/package.json index 7f8fb80..3507209 100644 --- a/template/base/package.json +++ b/template/base/package.json @@ -21,7 +21,8 @@ "@solidjs/start": "^0.7.4", "solid-js": "^1.8.15", "vinxi": "^0.3.10", - "@solidjs/meta": "^0.29.3" + "@solidjs/meta": "^0.29.3", + "zod": "^3.22.4" }, "engines": { "node": ">=16"