Skip to content

Commit

Permalink
fix: move from vite to app config
Browse files Browse the repository at this point in the history
  • Loading branch information
OrJDev committed Mar 13, 2024
1 parent ecb8ff9 commit aee3a7a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-socks-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-jd-app": patch
---

fix: move from vite to app config
18 changes: 6 additions & 12 deletions src/helpers/vite.ts → src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,27 @@ 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',
},`
: ""
}
},
})
`;
};

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)
);
}
};
2 changes: 1 addition & 1 deletion src/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IAppCtx> {
Expand Down
4 changes: 1 addition & 3 deletions template/base/vite.config.ts → template/base/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
start: {
ssr: true,
},
ssr: true,
});
3 changes: 2 additions & 1 deletion template/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit aee3a7a

Please sign in to comment.