Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update solid c3 configs to work with new solid-start beta-2 #4689

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/create-cloudflare/e2e-tests/frameworks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ describe.concurrent(`E2E: Web frameworks`, () => {
],
testCommitMessage: true,
timeout: LONG_TIMEOUT,
quarantine: true,
},
svelte: {
expectResponseToContain: "SvelteKit app",
Expand Down
31 changes: 9 additions & 22 deletions packages/create-cloudflare/src/frameworks/solid/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { logRaw, updateStatus } from "@cloudflare/cli";
import { brandColor, dim, blue } from "@cloudflare/cli/colors";
import { installPackages, runFrameworkGenerator } from "helpers/command";
import { compatDateFlag, usesTypescript, writeFile } from "helpers/files";
import { logRaw } from "@cloudflare/cli";
import { runFrameworkGenerator } from "helpers/command";
import { compatDateFlag } from "helpers/files";
import { detectPackageManager } from "helpers/packages";
import { viteConfig } from "./templates";
import type { FrameworkConfig, PagesGeneratorContext } from "types";

const { npm } = detectPackageManager();
Expand All @@ -18,31 +16,20 @@ const generate = async (ctx: PagesGeneratorContext) => {
const configure = async (ctx: PagesGeneratorContext) => {
process.chdir(ctx.project.path);

// Install the pages adapter
const pkg = "solid-start-cloudflare-pages";
await installPackages([pkg], {
dev: true,
startText: "Adding the Cloudflare Pages adapter",
doneText: `${brandColor(`installed`)} ${dim(pkg)}`,
});

// modify the vite config
const viteConfigPath = usesTypescript()
? `./vite.config.ts`
: `./vite.config.js`;
writeFile(viteConfigPath, viteConfig);
updateStatus(
`Adding the Cloudflare Pages adapter to ${blue(viteConfigPath)}`
);
// Note: we should update the vite.config.ts/js file here and set the preset on
// start.server.preset (as described in the solidStart docs: https://start.solidjs.com/api/vite#configuring-your-application)
// but that doesn't seem to work, so for now we just set the PRESET env variable in the build script
// later we should amend this when it's properly handled on solidStart's side
Comment on lines +19 to +22
Copy link
Member Author

@dario-piotrowicz dario-piotrowicz Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind, it actually does work, the config needs to look like this:

import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  start: {
    server: {
      preset: "cloudflare-pages"
    }
  }
});

(PS: I am pretty sure this didn't work when I opened the PR, maybe they've fixed it upstream 🤷 )

};

const config: FrameworkConfig = {
generate,
configure,
displayName: "Solid",
getPackageScripts: async () => ({
build: (cmd) => `PRESET=cloudflare-pages ${cmd}`,
"pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 3000 -- ${npm} run dev`,
"pages:deploy": `${npm} run build && wrangler pages deploy ./dist/public`,
"pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
}),
};
export default config;